我有一個sql查詢; 這個例子切爾西隊贏,輸,畫比賽結果 但我想在一個行SQL獲勝,繪製,丟失每個團隊的表格
對於離查詢結果(每隊):
切爾西W,W,L,d,W
阿森納W,d,d,L,L
ManCity d,W,L,d,W
Select date, Team, (case when fthg > ftag then 'W' when fthg = ftag then 'D' when ftag > fthg then 'L' end) from ( select div, hometeam team, date, fthg, ftag from Matches union all select div, awayteam team, date, ftag, fthg from Matches ) a where Team like '%chelsea%' order by date desc, team desc
date Team Mres 2016-08-15 00:00:00.000 Chelsea W 2016-08-27 00:00:00.000 Chelsea W 2016-09-16 00:00:00.000 Chelsea L 2016-10-15 00:00:00.000 Chelsea W 2016-10-23 00:00:00.000 Chelsea W 2016-11-05 00:00:00.000 Chelsea W 2016-11-26 00:00:00.000 Chelsea W 2016-12-11 00:00:00.000 Chelsea W 2016-12-26 00:00:00.000 Chelsea W 2016-12-31 00:00:00.000 Chelsea W 2017-01-22 00:00:00.000 Chelsea W 2017-02-04 00:00:00.000 Chelsea W 2017-02-25 00:00:00.000 Chelsea W 2017-04-01 00:00:00.000 Chelsea L 2017-04-05 00:00:00.000 Chelsea W
我如何得出每個團隊的排風格
有人能幫助我嗎? Thanx
什麼是期望的輸出?我猜你想要動態地調整數據......這在應用程序代碼中更好。 – GurV
您正在使用哪些DBMS? –
切爾西L,W,W,L,W ....這個慾望輸出 –