| Author |
Topic |
|
Xerxes
Aged Yak Warrior
666 Posts |
Posted - 2005-02-15 : 10:58:44
|
| Did a search, but found no answer to this...To get the first 47 records of a given table I can do this: SELECT TOP 47 * FROM tab_Work...the question is: How do I get the LAST 47?Semper fi, Xerxes, USMC(Ret.)-------------------------------------------------------------------------Once a Marine Programmer Analyst ALWAYS a Marine Programmer Analyst |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-02-15 : 11:11:03
|
SELECT TOP 47 * FROM tab_Work order by someCol desc you do know that order of data in a table isn't guaranteed, no?Go with the flow & have fun! Else fight the flow |
 |
|
|
Xerxes
Aged Yak Warrior
666 Posts |
Posted - 2005-02-15 : 11:16:38
|
Mladen ....I know this much: in the IT world NOTHING is GUARANTEED. Thanks again!Semper fi, Xerxes, USMC(Ret.)-------------------------------------------------------------------------Once a Marine Programmer Analyst ALWAYS a Marine Programmer Analyst |
 |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2005-02-15 : 15:32:14
|
| >>> you do know that order of data in a table isn't guaranteed, no? <<<Xerxes is a Senior Database Analyst... Of course he knows that!!!HTH=================================================================Egotism is the anesthetic that dulls the pain of stupidity. -Frank William Leahy, football coach (1908-1973) |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-02-15 : 15:33:59
|
it was a joke, and i think he got it as such... don't loose you kool, bustaz. Go with the flow & have fun! Else fight the flow |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-02-15 : 15:55:26
|
| >>it was a joke, and i think he got it as such... Actually, I am not sure of this based on his response, to be honest ... Xerxes -- you know that he wasn't joking, right? the order of the data retrieve is NOT gauranteed w/o an explicit ORDER BY clause. there is no such thing as the "last N records" in a table w/o columns that are populated with values that will allow you to determine that.- Jeff |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-02-16 : 00:40:49
|
| Will this work?If there is no Identity column then temporarily add that column, select this and drop that columnDeclare @end numericDeclare @Start numericSelect @end=Max(Id) from tableset @Start= @end-46select @end,@Startexec('select * from table where Id between '+@Start+' and '+@end)Madhivanan |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-02-16 : 12:47:04
|
quote: Originally posted by Xerxes ....I know this much: in the IT world NOTHING is GUARANTEED.
Only for some...and I keep the others at bay....Brett8-) |
 |
|
|
Xerxes
Aged Yak Warrior
666 Posts |
Posted - 2005-02-16 : 13:19:30
|
quote: Originally posted by spirit1 it was a joke, and i think he got it as such... don't loose you kool, bustaz. Go with the flow & have fun! Else fight the flow 
I go the joke....although, I am puzzled that that my perception of a joke is fodder for discussion! Semper fi, Xerxes, USMC(Ret.)-------------------------------------------------------------------------Once a Marine Programmer Analyst ALWAYS a Marine Programmer Analyst |
 |
|
|
|