如何对当前查询求和或添加 (PDetail.DETAIL_FOR_QTY)?
SELECT PDetail.PLU, PDetail.DETAIL_FOR_QTY, PLU.PLU_DESC, PLU.LAST_PRICE
FROM PDetail INNER JOIN
PLU ON PDetail.PLU = PLU.PLU_NUM
WHERE (PDetail.DEPT = 26) AND (PDetail.StoreNumber IN (1, 2, 3, 4, 7, 8, 10, 12, 14, 16)) AND (PDetail.TIME_STAMP BETWEEN CONVERT(DATETIME,
'2013-06-20 00:00:00', 102) AND CONVERT(DATETIME, '2013-06-20 23:59:59', 102))
ORDER BY PLU.PLU_DESC
目前,我得到这样的东西:
08024401 1 item1 17.4900
08048003 1 item2 22.9900
08048004 1 item3 22.9900
08048004 1 item3 22.9900
我试图将这两个相加,因为它们是相同的(基于 PDetail INNER JOIN PLU ON PDetail.PLU = PLU.PLU_NUM):
PDetail.PLU PDetail.DETAIL_FOR_QTY PLU.PLU_DESC Don't need to add this
08048004 1 item3 22.9900
08048004 1 item3 22.9900
期望的结果:
08024401 1 item1 17.4900
08048003 1 item2 22.9900
08048004 2 item3 22.9900