這是我的腳本如何將輸出結果更改爲零的sql腳本?
SELECT a.iPriority_num AS [TransNUM],b.sItem_nm as [Item],a.mSellingPrice_amt AS [aMT],
SUM(c.mCash_amt) AS [CASH]
,SUM(c.mCCard_amt) AS [CC]
,SUM(c.mEPS_amt) AS [CEPS]
,SUM(c.mGCheque_amt) AS [GC]
,SUM(c.mCheque_amt) AS [OTHERS]
FROM Table1 a
LEFT JOIN Table2 b
ON a.sPlu_cd=b.sPlu_cd
LEFT JOIN Table3 c
ON a.iPriority_num=c.iPriority_num AND
a.iBranch_num=c.iBranch_num
AND b.iCompany_typ=c.iCompany_typ
WHERE a.IAPPLY_DT BETWEEN 20130701 AND 20130731
AND a.iBranch_num=14
AND a.iStatus_typ=1
AND a.sSellUnit_CD='PC'
AND a.IPRIORITY_NUM=118271
GROUP BY
a.iPriority_num,b.sItem_nm,a.mSellingPrice_amt
結果是
TransNUM Item Price Cash CC EPS GC others
118271 Item1 204.0000 392.0000 .0000 .0000 .0000 .0000
118271 Item2 188.0000 392.0000 .0000 .0000 .0000 .0000
我想讓第二行(392)的值只有0。我在這裏使用SQL 2000。
我很好奇。爲什麼你希望查詢輸出爲零,而不是在你的後臺修改它 –
任何特定的RDBMS? –
@RowlandShaw我相信這是MSSQL,因爲在查詢中有方括號 –