面试之SQL(1)--选出选课数量>=2的学号

来源:互联网 发布:磁盘元数据测试0x32 编辑:程序博客网 时间:2024/06/05 10:51

ID      Course

1AA1BB2AA2BB2CC3AA3BB3CC3DD4AANULLNULL

选出选课数量>=2的学号

 

select distinct ID from test as A

where (Select count(ID) from test as B where A.ID=B.ID)>=2

 

1
2
3

0 0