Thursday, May 7, 2009

Efficient way to count rows when using GROUP BY

Hi All,

One of my friends wanted to find out number of rows returned by a query while he was using group by statement in it.

I found a interesting way to get this while I was browsing google.. here is the query to return count of number of rows while using group by,

Select count(count1) from (SELECT Count(*) as count1 from TABLE where CONDITION B group by Fieldname) t1

Regards,
Karan

No comments:

Post a Comment

My Stats