Wednesday, September 15, 2010

Compare two counts in where clause in sqlserver 2005

We can compare two counts in where clause of select statement:

Select * from Emp where
 (
  (select count(*) from dept where ISactive=1) = (select count(*) from dept where Status=1)
 )

In this case it fetch records only the counts are equal...

No comments:

Post a Comment