
想要得到如上結果。我的陳述句:
select a.SaleId, CAST( convert(varchar(10), a.date,112) AS DATE) '單據日期',a.CodeId'渠道號',
b.GoodsNo '貨號',c.Color '顏色編號','0' '內長',
case when c.S1<>0 then 'S1'
when c.S2<>0 then 'S2'
when c.S3<>0 then 'S3'
when c.S4<>0 then 'S4'
when c.S5<>0 then 'S5'
when c.S6<>0 then 'S6'
when c.S7<>0 then 'S7'
when c.S8<>0 then 'S8'
when c.S9<>0 then 'S9'
when c.S10<>0 then 'S10'
when c.S11<>0 then 'S11'
when c.S12<>0 then 'S12'
when c.S13<>0 then 'S13'
when c.S14<>0 then 'S14'
end
'尺碼', b.Quantity '數量',b.Price*b.Quantity '生意額' from 表A a
right join 表B b on a.SaleID=b.SaleID
right join 表C c on b.SaleIDNum=c.SaleIDNum where a.CheckDate = '2021-04-05' and Posted=1 and Customer_ID ='172101'
我用以上陳述句,得到如下結果,不是我想要的。

SQL陳述句如何寫得到如下結果:

轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/272712.html
標籤:疑難問題
上一篇:普通檔案就不能免費嗎
