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
 Transact-SQL (2000)
 Top 2 in child rows

Author  Topic 

sotian
Starting Member

8 Posts

Posted - 2007-03-09 : 05:58:46
Hello,

I have two tables, a header table, and child table.

The child table contains a range of dates.

In a stored procedure I want to return the header table, and separately the child table, but only the top 2 items relating to the header table.

So:

Select * From header

Select top 2 * From Child order by childdate

This obviously only returns the top two child records instead of the top 2 per header record.

Help would be appreciated

Thanks,
Jon

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-03-09 : 06:20:42
http://weblogs.sqlteam.com/mladenp/archive/0001/01/01/7421.aspx
point 2

_____________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page
   

- Advertisement -