Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

returning rows

Status
Not open for further replies.

database1

Technical User
Joined
May 15, 2000
Messages
8
Location
IN
which is the function that will answer queries such as <br>-select first five rows in a table<br>-select last five rows<br>-even rows <br>-odd rows
 
<i>-select first five rows in a table</i><br>select top 5 * from mytable<br><br><i>-select last five rows</i><br>select top 5 * from mytable order by mycolumn desc<br><br>As to the other two, I can't think of anyway short of a stored procedure walking a cursor, absent some column in the table that would help (for example, an integer PK column). <p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br>
 
If you have a identity column(if using SQL Server) or Autoincrement column (if using MS Access). Retrieve this ID column by using a mod of 2. If the mod is 0 then that is even if mod is not 0 then it is odd. <br><br>In case you don't know what MOD is, it is the remainder of division. So you would have to loop through the recordset, do ID MOD 2, if the answer is 0 (this is your even record) and if the answer is NOT 0 (this is your odd records). <br><br>LuvASP.
 
How to get the records between 5 and 10.?
For example,
If &quot;select * from employee&quot; is returing 100 records.
How to get the records from 5 to 10?

Selva Balaji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top