This is a discussion on Retrieve only the Nth row from a table? within the Database Support forums, part of the Web Development category; can one Retrieve only the Nth row from a table? Thanks in advance...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| can one Retrieve only the Nth row from a table? Thanks in advance |
|
#2
| |||
| |||
| MySQL create table test_nthrow ( id integer , name varchar(100) ); insert into test_nthrow values (1,'row 1'); insert into test_nthrow values (2,'row 2'); insert into test_nthrow values (3,'row 3'); insert into test_nthrow values (4,'row 4'); insert into test_nthrow values (5,'row 5'); to get nth row use (n-1) in LIMIT condition since mysql rownumber starting from 0 to get 5th row select * from test_nthrow limit 4,1 Quote:
Oracle In oracle you may use this query to get 5th row select * from (select ROWNUM rn,t.* FROM test_nthrow t) WHERE rn=5 This is just one way getting Nth row, you can use alternate method also in this case .
__________________ Keep smiling... |
|
#3
| |||
| |||
| Hi Priyan it is very useful for me. but i need query for sql server 2005 |
|
#4
| |||
| |||
| Hi Santha, I think this will help you , Begin With ProjectTable As (Select *, Row_Number()Over(Order By ProjectID) as RowNum from Project) Select * from ProjectTable Where RowNum = 9 End Here the 'ProjectTable' is the Common Table Expression used to hold the result set of the project table temporarily. You can use any table instead of project table. Tell me How usefull was it Thanks, L.Srikumar |
|
#5
| |||
| |||
| Hi Santha, You can try this also, Select * From (Select *,(Row_Number() Over (Order By ProjectID)) As Rownum From Project) P Where P.Rownum = 10 |
|
#6
| |||
| |||
| Hi This query is very useful for me . its working fine in sql server . can u please explain this query.? Thank u |
|
#7
| |||
| |||
| is really useful for me, I am glad to read it here. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to Retrieve a Cookie Value? | sundarraja | PHP Programming | 4 | 04-02-2008 06:00 AM |
| Retrieve mails from server | kingmaker | C# Programming | 6 | 12-14-2007 10:42 PM |
| What is the difference between DELETE TABLE and TRUNCATE TABLE commands in SQL Server | oxygen | Database Support | 6 | 11-23-2007 05:17 AM |
| How do I retrieve the values from the URL? | Pvinothkumar | HTML, CSS and Javascript Coding Techniques | 1 | 09-13-2007 05:30 AM |
| which method to use so that last inserted value can be retrieve. | KiruthikaSambandam | Database Support | 1 | 08-06-2007 11:13 PM |
Our Partners |