我試圖將下面的結果按文章分組顯示。 這可能嗎?
因此,最終我只會有2行。 來自TYPE I & W的數據將被合併。合併結果行
到我的查詢圖像,如下
image http://tikistudio.sg/F002.jpg
查詢如下
SELECT INTSALEID as RECEIPT,
STRSALETYPE as TYPE,
STRORDERCODE as ARTICLE,
max(case when strsaletype='I' then DBLQTYSOLD else null end) as [QTY SOLD],
max(case when strsaletype='I' then CURSELLPRICE1 else null end) as [UNIT PRICE],
max(case when strsaletype='W' then CUROFFERDISCOUNT else null end) as [DISCOUNT],
max(case when strsaletype='I' then CURFOREIGNAMT else null end) as [GROSS AMOUNT]
FROM DAILYSALES
WHERE STRTRADECODE='MM01'
and DTMTRADEDATE='01-01-2015' and INTSALEID='31086'
and STRSALETYPE in ('I','W')
GROUP BY STRORDERCODE,STRSALETYPE,INTSALEID,DBLQTYSOLD,CURSELLPRICE1,
CURFOREIGNAMT,CURDISCOUNT,CUROFFERDISCOUNT
你能分享一些樣本數據和你試圖得到的結果嗎? – Mureinik