01
2012
06

一个SQL 语句

Select 酒菜编号,点单类型,case 点单类型 when '点单' then sum(数量) end as 点单数量,case 点单类型 when '退单' then sum(数量) end as 退单数量,sum(数量) as 总数 from 表名 group by 酒菜编号,点单类型

运行测试

SELECT inno, inout, CASE inout WHEN '入库' THEN SUM(QTY) END AS 入库数量, CASE inout WHEN '出库' THEN SUM(QTY) END AS 出库数量
FROM TabInOut
GROUP BY inno, inout
ORDER BY inno DESC, inout DESC

« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。