答案 0 :(得分:3)
您可以使用group by
和having
进行此操作:
select name
from t
where course in ('Eng', 'Geo')
group by name
having max(case when course = 'Eng' then score end) > max(case when course = 'Geo' then score end);
如果每个名称/课程只有一个分数,则也可以使用join
,例如:
select teng.name
from t teng join
t tgeo
on teng.name = tgeo.name and
teng.course = 'Eng' and
tgeo.course = 'Geo' and
teng.score > tgeo.score;