我需要在SQL server 2008上找到所有有一列属于相同值的记录,同时满足一个条件。
col1 col2
100 0
100 1
100 1
200 0
200 0
200 0
300 0
300 0
200 0
我需要得到所有col2=0的行,这些行与col1相同。
在这里,我希望
col1 col2
200 0
200 0
200 0
300 0
300 0
300 0
因为对于col1=200和col1=300,所有col2都是0。
SELECT *
FROM table1 as a
where a.col2 = 0 # but, how to say col1 belong to the same value ?