请教各位一个SQL语句
表TAB如下:
MONTH NAME
1 MM
2 MM
3 MM
1 JJ
2 JJ
查询1-3月都有数据的NAME,上面的结果是MM
------解决方案--------------------
请教各位一个SQL语句
表TAB如下:
MONTH NAME
1 MM
2 MM
3 MM
1 JJ
2 JJ
查询1-3月都有数据的NAME,上面的结果是MM
select m.name from
(select name , count(*) as cnt from tab group by name) m,
(select count(*) as cnt from (select distinct month from tab) t) n
where m.cnt = n.cnt