oracle查詢結果的行轉列


想把結果的日期給弄成橫排。所以就這樣弄了。

select t.DXID AS 姓名,
sum(decode(t.CJSJ,'2019-05-01',RCYL,null))怪事,
sum(decode(t.CJSJ,'2019-05-02',RCYL,null))數字,
sum(decode(t.CJSJ,'2019-05-03',RCYL,null))為啥
from JCCDJNHRB t group by DXID order by DXID desc

 

再加一句

 

SELECT a.dxid,
sum(decode(a.CJSJ,'2019-05-01',RCYL,null))怪事,
sum(decode(a.CJSJ,'2019-05-02',RCYL,null))數字,
sum(decode(a.CJSJ,'2019-05-03',RCYL,null))為啥

from JCCDJNHRB a, dbaa061 b, DBBA021 c
where cjsj <= to_date('2019-05-03', 'yyyy-mm-dd ')
and cjsj >= to_date('2019-05-01', 'yyyy-mm-dd ')
and a.DWDM = '011101'
and a.dwdm = b.dwdm
and a.dxid = c.dxid
group by a.dxid order by a.dxid asc


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM