Hi friends,
I have come across a very strange feature.Can someone please explain to me as to how it works out.Basically a query to get the row counts of a group by having caluse.
This is the pseudo code
select count(isnull MAX(TAB.COL2),0))
from TAB
where
TAB.COL1=<value>
and TAB.COL3=<value>
group by
TAB.COL1,TAB.COL2
having
TAB.COL1=<value>
and TAB.COL3=<value>
and TAB.COL5=MAX(TAB.COL5)
Now what I see is this query is returning the rowcount of such records.I was expecting it to return the number of rows for each of the groups in the where and having clause.By removing the MAX clause I get that result.How is the processor exactly processing this query to return the number of rows? I set the showplan on but that was not of much help!
Can someone please explicitly explain the query steps that are followed for this query ?
Thanks in advance
Somnath
I have come across a very strange feature.Can someone please explain to me as to how it works out.Basically a query to get the row counts of a group by having caluse.
This is the pseudo code
select count(isnull MAX(TAB.COL2),0))
from TAB
where
TAB.COL1=<value>
and TAB.COL3=<value>
group by
TAB.COL1,TAB.COL2
having
TAB.COL1=<value>
and TAB.COL3=<value>
and TAB.COL5=MAX(TAB.COL5)
Now what I see is this query is returning the rowcount of such records.I was expecting it to return the number of rows for each of the groups in the where and having clause.By removing the MAX clause I get that result.How is the processor exactly processing this query to return the number of rows? I set the showplan on but that was not of much help!
Can someone please explicitly explain the query steps that are followed for this query ?
Thanks in advance
Somnath