Team Results
A Win
B Win
A Loss
B Draw
C Loss
C Loss
Team Win Loss Draw Total
A 1 1 0 2
B 1 0 1 2
C 0 2 0 2
答案 0 :(得分:1)
请查看以下查询:
SELECT Team, SUM(w) AS Win, SUM(l) AS Loss, SUM(d) AS Draw, SUM(w)+ SUM(l)+ SUM(d) AS
Total
FROM
(
SELECT Team, IF(Results = 'Win',1,0) AS w, IF(Results = 'Loss',1,0) AS l, IF(Results =
'Draw',1,0) AS d
FROM table1) a
GROUP BY Team