关系划分-SQL-只显示获得某些奖励的用户



我有一个类似的Access用户数据库

UserName |
Award |
DateGiven

我们分配各种类型的奖项。每个奖励任务都有一个单独的条目。我需要能够找到哪些用户被分配了3个特定的奖项。

例如:

我们分配奖励a、b、c、d、e和f。

john, a, 01/01/14|
bill, b, 02/02/14|
john, c, 01/02/14|
mary, a, 01/01/14|
sue, e, 01/01/14|
john, b, 01/01/14|

我需要能够显示哪些用户被分配了奖励a、b和c,所以从上面来看,它只显示John。

想法?

select username
from your_table
where award in ('a','b','c')
group by username
having count(distinct award) = 3
select username
from your_table
where award in ('a','b','c','d','e','f');

最新更新