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)
 SQL Nested Queries with Group By Clause

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-08-31 : 09:36:52
campite writes "Hi. This is more of conceptual question than actual code syntax. I'm creating a catalog and would like to display 5 items at a time. I have a query built with the following structure:

Select [top 5] xxx
From xxx
Where xxx
Group by xxx


Now this query will return the first 5 results. What I want to do is build another query that returns the next 5 results. So I tried something like this:

Select [top 10] xxx
From xxx
Where xxx
AND NOT IN (Select [top 5] xxx
From xxx
Where xxx
Group by xxx)
Group by xxx


Is this possible? Can you create nested queries with the Group By clause? Do I need to use the Having Clause? Help!
"
   

- Advertisement -