Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Group By Problem

Author  Topic 

Krilyn
Starting Member

7 Posts

Posted - 2005-10-12 : 19:04:52
Basically setup is this

Select A, B from table
Group by A, B Having C

problem is I need to have a having thats not in the group by and it won't let me since due to that fact. If anyone has any help it would be greatly appreciated.

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2005-10-12 : 19:10:28
You're going to have to be more specific if you want a specific answer. But in short, you are correct. The HAVING is applied after the grouping is done, and therefore it can only reference things in the GROUP. On the other hand, if what you really wanted was to filter out rows before grouping, then you can still put in a WHERE clause between the FROM and GROUP BY clauses.

---------------------------
EmeraldCityDomains.com
Go to Top of Page

Krilyn
Starting Member

7 Posts

Posted - 2005-10-12 : 19:13:29
That answers my question. Didn't lay it out as well as I wanted to. Thanks for the information.
Go to Top of Page
   

- Advertisement -