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)
 Return every other row from a Table

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-08-02 : 09:42:02
Tony writes "I have a table with dates and events.

I need to retrieve from the table, in date order, each alternate row. I then need to retrieve separately the rows that were skipped.

This would leave me with two recordsets representing the odd and even rows respectively.

I could do this in code, but the object I need to pass the recordsets to have an insurmountable insect-like 'feature'

Thanks"

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-08-02 : 09:46:58
quote:

... the object I need to pass the recordsets to have an insurmountable insect-like 'feature'...


WOW!! I have no idea what that means....

Anyway, to do what you want, you should build a temp table from your rowset with an identity column and ordered by the date. Then using the modulo operator, select from the temp table only those records you DO want to return...

Jay White
{0}
Go to Top of Page
   

- Advertisement -