我有兩個表AORDER購買& BORDER出售。我想獲得待定數量。對於一個採購訂單,銷售訂單可以有多個記錄。我不希望顯示有那些爲了未決數量的0。我試過這樣:Visual Foxpro查詢待定數量
SELECT ;
aorder.orderid,;
aorder.orderdate,;
aorder.itemname,;
aorder.partyname,;
aorder.qty as Purchase,;
SUM(border.qty) AS Sale,;
SUM(aorder.qty-border.qty) as Pending;
FROM ;
aorder;
LEFT JOIN border ;
ON aorder.orderid = border.porderid;
GROUP BY ;
aorder.orderid,;
aorder.orderdate,;
aorder.itemname,;
aorder.partyname,;
aorder.qty
但我無法隱藏其購買數量=銷售數量的記錄。
Thnx提前。
添加'HAVING'子句查詢。例如, 'HAVING SUM(aorder.qty - border.qty)> 0' – shahkalpesh 2013-03-11 08:08:41