User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 391,735 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,215 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser:
Views: 454 | Replies: 1
Reply
Join Date: Jun 2007
Posts: 15
Reputation: guptaalok12 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
guptaalok12 guptaalok12 is offline Offline
Newbie Poster

How To get the 5th row from a table.

  #1  
Jul 12th, 2008
How To get the 5th row from a table.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2008
Posts: 295
Reputation: tesuji is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 41
tesuji tesuji is offline Offline
Posting Whiz in Training

Re: How To get the 5th row from a table.

  #2  
Jul 12th, 2008
Hello guptaalok12,

When Edgar Frank Codd invited relational databases his primary idea was to found it on logic algebra and set theory. The Rows of relational tables (aka relations) are sets. Therefore, there aren't duplicate rows nor any particular order of rows. From this point of view, asking "How To get the 5th row from a table?" is irrelevant. Yet, to put any meaningful signification on it, your table must already have a column which allow such an ordering, for example: Birthday in a person's record. Now it would be possible ordering all persons' records by birthday to find: "Who is the fifth oldest person?". If you don't have such a special column (or set of columns) within a table, it is impossible to determine the 5th row because the 5th row you get today will be the 8th row tomorrow (e.g. due to inserting and deleting rows in the meantime).

On sql server (>2000) you can get the 5th row from our person's birthday example by two nested top clauses:
SELECT TOP 1 name, birthday 
FROM 
(   SELECT TOP 5 name, birthday FROM persons 
    ORDER BY birthday ASC
) suse
ORDER BY birthday DESC
krs,
tesu
Information is moving—you know, nightly news is one way, of course, but it's also moving through the blogosphere and through the Internets. I promise you I will listen to what has been said here, even though I wasn't here. Ann and I will carry out this equivocal message to the world. I'm the master of low expectations.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MS SQL Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 3:51 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC