例如我们有:
URL Schemes
我只想输出一个将苹果作为其唯一属性的人员列表。所以这份名单只包括莉莉。
我该怎么做?
谢谢你们!
答案 0 :(得分:1)
您只需要GROUP BY
SELECT name FROM
table t
GROUP BY name
HAVING COUNT (*) = 1 and
SUM(CASE WHEN fruit = 'apple' THEN 1 ELSE 0 END) = 1
答案 1 :(得分:0)
以下代码对您有所帮助,
select distinct name
from your_table_name a
where fruit = 'apple' and name not in (select name from your_table_name b where b.name = a.name and b.fruit!='apple')