SQL Recipes (Beta II)
A FREE cookbook for SQL queries and examples
Register FAQ Search Today's Posts Mark Forums Read

SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it.

Go Back   SQL Recipes a FREE cookbook of SQL queries and examples > SQL queries and examples > SQL - Questions and Answers

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
  #1 (permalink)  
Old 08-05-2006, 05:47 PM
nagu
 
Posts: n/a
Default SQL 92 dialect question:

how can i select the third row from table?


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Edit/Delete Message Reply With Quote

ANSWER(S):

  #2 (permalink)  
Old 08-21-2006, 02:04 AM
Dimitar
 
Posts: n/a
Default SQL 92 answer. Re: how can i select the third row from table?

SELECT max(a) FROM t WHERE a < (SELECT max(a) FROM t WHERE a < (SELECT max(a) FROM t));
What will the above return if the table is less than 3 in cardinality?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Edit/Delete Message Reply With Quote
  #3 (permalink)  
Old 09-22-2006, 05:12 AM
charlesryoung charlesryoung is offline
Junior Member
 
Join Date: Sep 2006
Posts: 3
charlesryoung is on a distinguished road
Default Oracle answer. Re: how can i select the third row from table?

In most databases, the order of rows in the table are not required to be consistent from one time to another unless you use the ORDER BY statement. Even though it appears that you always see the same order when you SELECT * FROM tbl, you cannot rely on that as new versions of the database come out.

So the answer to that question depends on what you order by. If you have a customer table ordered by last name, what does the "third row" tell you? Please explain a scenario where getting the third row would be required.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-05-2007, 11:02 AM
deepak garg deepak garg is offline
Junior Member
 
Join Date: Dec 2007
Posts: 6
deepak garg is on a distinguished road
Wink ANY answer. Re: how can i select the third row from table?

You can use this and can select whichever row you want to select:

select * from (select rownum r,col_1,col_2,col_3,col_4 from table_name) t
where t.r='&z'

Last edited by deepak garg : 12-05-2007 at 11:05 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Moderation Tools:



All times are GMT. The time now is 05:04 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
Copyright (c) 2006-2007 SQL Recipes

1 2 3 4 5 6 7