SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 query help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sunsanvin
Flowing Fount of Yak Knowledge

India
1266 Posts

Posted - 10/09/2006 :  04:10:59  Show Profile  Send sunsanvin a Yahoo! Message  Reply with Quote
hi friends,
i need a query to display the rows from 2 to 5 records.

suppose i have 100 records in my table.

i need records from 2 to 5 only.

thanks in advance

SwePeso
Patron Saint of Lost Yaks

Sweden
30241 Posts

Posted - 10/09/2006 :  04:19:59  Show Profile  Visit SwePeso's Homepage  Reply with Quote
How do you determine row/record order?


Peter Larsson
Helsingborg, Sweden

Edited by - SwePeso on 10/09/2006 04:20:12
Go to Top of Page

harsh_athalye
Flowing Fount of Yak Knowledge

India
5518 Posts

Posted - 10/09/2006 :  04:36:12  Show Profile  Visit harsh_athalye's Homepage  Click to see harsh_athalye's MSN Messenger address  Send harsh_athalye a Yahoo! Message  Reply with Quote
Refer this article, point # 13:

http://weblogs.sqlteam.com/mladenp/archive/2005/08/01/7421.aspx

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

chiragkhabaria
Flowing Fount of Yak Knowledge

India
1907 Posts

Posted - 10/09/2006 :  05:47:52  Show Profile  Visit chiragkhabaria's Homepage  Send chiragkhabaria a Yahoo! Message  Reply with Quote
If you have primary key in your table, then have a look at the following script


SELECT        (SELECT COUNT(i.au_id) 
               FROM pubs..authors i 
               WHERE i.au_id >= o.au_id ) AS RowID, 
              au_fname + ' ' + au_lname AS 'Author name'
FROM          pubs..authors o
ORDER BY      RowID


This will generate the RowId and then accordingly you can select the rows which you want sepcifying the range in the where clause.

if you are using SQL Server 2005 then have a look at following link.
http://www.sqlservercentral.com/columnists/mcoles/sequentialordering.asp


Chirag

http://chirikworld.blogspot.com/
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22755 Posts

Posted - 10/09/2006 :  09:35:44  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Do you need Pagination?

http://weblogs.sqlteam.com/jeffs/archive/2003/12/22/672.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 10/09/2006 :  09:58:33  Show Profile  Reply with Quote
The physical order of data in a database has no meaning

What purpose does it serve you to say you want rows 2 thru 5?

Tell us what value rows 2 thru 5 have, then we can help



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000