Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-08-18 : 07:57:36
|
| Mack writes "I want to select last 2 records from a table AA which has following 5 records.111222333444555There is no primary key. Any tip will be really appretiated. Thanks for taking time to read it." |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-08-18 : 08:00:09
|
| Hi Mack, Welcome to SQL Team!You will have to declare some sort of ORDER BY to get the "last two" - SQL has no concept of an order to the data - so if you need the last two in order or data entry you will need a "Create Date" column in the record.SELECT TOP 2 *FROM MyTableORDER BY MyColumnKristen |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-18 : 08:11:13
|
| You need to define last twoSELECT TOP 2 *FROM MyTableORDER BY MyColumn DESCMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|