有一张挑战赛记录表Info表如下,有三个字段id、name、score,不能选出每个name的score最高的记录的sql是(要包含所有字段)
+---------+--------+-------+
| id | name | score |
+---------+--------+-------+
| 1 | B | 9.95 |
| 2 | A | 10.99 |
| 3 | C | 1.69 |
| 4 | B | 19.95 |
| 5 | A | 6.96 |
+---------+--------+-------+
A.
select id,name,score
from Info s1
where score = (
select max(s2.score)
from Info s2
where s1.name=s2.name);
B.
select id,s1.name,s1.score
from Info s1
join (
select name,max(score) score
from Info
group by name) s2
on s1.name=s2.name and s1.score=s2.score;
C.
select s1.id,s1.name,s1.score
from Info s1
left join Info s2
on s1.name=s2.name and s1.score<s2.score
where s2.id is null;
D.
select s1.id,s1.name,s1.score
from Info s1
left join Info s2
on s1.name=s2.name and s1.score>s2.score
where s2.id is null;