Monday, March 12, 2012

Row Count using Group By and Having

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
select count(*) from
(<Your sql querey > ) dr
Here dr is name for derived table
Hth
"Kiran" <Kiran@.nospam.net> wrote in message
news:uGd396EAFHA.1296@.TK2MSFTNGP10.phx.gbl...
> 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
>
>|||Thanks a lot
That's exactly what I wanted
Kiran
"AM" <shahdharti@.gmail.com> wrote in message
news:ud6otJFAFHA.2552@.TK2MSFTNGP09.phx.gbl...
>
> select count(*) from
> (<Your sql querey > ) dr
> Here dr is name for derived table
> Hth
> "Kiran" <Kiran@.nospam.net> wrote in message
> news:uGd396EAFHA.1296@.TK2MSFTNGP10.phx.gbl...
>|||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
"Kiran" <Kiran@.nospam.net> wrote in message
news:uGd396EAFHA.1296@.TK2MSFTNGP10.phx.gbl...
> 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
>
>

No comments:

Post a Comment