表1
日期 | 队名 | 结果 |
2017/5/9 | A | 胜 |
2017/5/10 | A | 胜 |
2017/5/11 | A | 负 |
2017/5/12 | B | 负 |
2017/5/13 | B | 胜 |
2017/5/14 | B | 负 |
2017/5/15 | B | 负 |
2017/5/16 | A | 胜 |
2017/5/17 | A | 负 |
2017/5/18 | B | 负 |
2017/5/19 | B | 胜 |
2017/5/20 | B | 负 |
2017/5/21 | A | 胜 |
2017/5/22 | A | 负 |
2017/5/23 | A | 胜 |
2017/5/24 | A | 负 |
2017/5/25 | B | 负 |
2017/5/26 | B | 胜 |
2017/5/27 | B | 负 |
2017/5/28 | B | 负 |
2017/5/29 | A | 胜 |
2017/5/30 | A | 负 |
2017/5/31 | B | 负 |
2017/6/1 | B | 胜 |
问题:如果胜的数量大于5请将此队的排名标记为冠军团队,否则标记为亚军团队
select 队名,(select COUNT(*) from 测试 a where 结果 = '胜' and a.队名 = b.队名) as 胜利次数,(case when (select COUNT(*) from 测试 a where 结果 = '胜' and a.队名 = b.队名) > 5 then '冠军团队' else '亚军团队' end) as 荣誉 from 测试 b group by 队名
sql中的if就是case when ....then else .... end
有什么不明白的地方吗?