日期:2014-05-17  浏览次数:20755 次

求一SQL语句?
表table如下
A B
11 1
11 2
12 1
12 1
13 1
14 3
14 3
15 1
15 3
现在要取出的结果如下; B为1,A所对应的B里只能为1,不能为其它,
结果如下:
12 1
12 1
13 1
请问这段SQL怎么写??

------解决方案--------------------
Select * from table t Where B=1 and not exists
 (Select 1 from table where A=t.A and B<>1)