以下有两张表,需要合并按投资额度倒序排序
SELECT time 时间, sum(case when score= "90" then 1 else 0 end) as 胜,sum(case when result = "负" then 1 else 0 end) as 负 from Student GROUP BY time;
- 简要说明:
- when score= “90” : 为判断条件,
- then 1 selse 0 end: 当以上判断条件成立,则为1; 而该语句是在sum中的,具有累加效果,即可实现对所有成绩为90分的人进行一个统计
- 另外,由于count中无法使用条件语句,所以,此处使用sum而不用count