all groups > sql server new users > january 2005 >
You're in the

sql server new users

group:

Row Count using Group By and Having


Row Count using Group By and Having Kiran
1/22/2005 12:49:24 AM
sql server new users:
Hi,

I have a query that uses Group By and Having to retrieve records.

The query is working fine and I want to get the Row Count of that Query.

How will I do that.

Thanks
Kiran


Re: Row Count using Group By and Having Kiran
1/22/2005 1:34:39 AM
Thanks a lot

That's exactly what I wanted

Kiran

[quoted text, click to view]

Re: Row Count using Group By and Having AM
1/22/2005 12:42:46 PM


select count(*) from
(<Your sql querey > ) dr

Here dr is name for derived table

Hth

[quoted text, click to view]

Re: Row Count using Group By and Having Lee Tudor
1/22/2005 8:47:37 PM
If you are already executing the base query in the same batch, there are a
couple of extra considerations:

1) you may be double running a potentially expensive query putting extra
load on the server.
2) unless you encapsulate the two queries in a REPEATABLE READ transaction,
you could get inconsistent results.

in this case you can do:

<your select>
SELECT @@ROWCOUNT

Mr Tea
http://mr-tea.blogspot.com

[quoted text, click to view]

AddThis Social Bookmark Button