文章詳情頁
關于Mysql數據表行轉列
瀏覽:153日期:2022-06-13 14:39:16
問題描述
問題解答
回答1:試試下面的語句:
select team_name,sum(if(score=’正’,1,0)) as’正’,sum(if(score=’負’,1,0)) as ’負’ from teamscore group by team_name;回答2:
應該是:
SELECT team_name, count(*) AS win WHERE score = ’正’ GROUP BY team_nameSELECT team_name, count(*) AS loss WHERE score = ’負’ GROUP BY team_name
再想辦法把這兩個結果合起來。
相關文章:
排行榜