select b.mar_en_name, a.rd_name, a.shipto_code, a.inventory, a.twomonthtotalcost, 
round(((inventory/twomonthtotalcost)*61) , 1) as InventoryDays, smmonth 
from gl_distributor a, gl_et b 
where a.mar_code=b.mar_code and twomonthtotalcost<>0 and 
twomonthtotalcost is not null and hub_type_id=1 and smmonth='200609'  order by inventorydays having inventorydays>100

解决方案 »

  1.   

    同一个sql不可以马上使用别名。
    不可以这样,
    select a.x m
    from tab
    where m < 0
      

  2.   

    ndb96, 你写的语句测试后无法通过, 提示说"SQL 命令未正确结束".Eric_1999, 你说的问题我也发现了, 所以发上来问问大家有没有什么其他的解决方式!虽然问题还没有解决, 先谢谢上面两位的回答!
      

  3.   

    select b.mar_en_name, a.rd_name, a.shipto_code, a.inventory, a.twomonthtotalcost,
    round(((inventory/twomonthtotalcost)*61) , 1) as InventoryDays, smmonth
    from gl_distributor a, gl_et b
    where a.mar_code=b.mar_code and twomonthtotalcost<>0 and
    twomonthtotalcost is not null and hub_type_id=1 and smmonth='200609' and inventorydays>100 
    order by round(((inventory/twomonthtotalcost)*61) , 1)
      

  4.   

    xiaoxiao1984, 你写的语句依然有问题, 问题不是出现在order by后的条件, 而是where语句中的最后一个条件. 哎, 看来没有什么好办法了, 还是乖乖的用子查询吧!最后多谢大家的回答!