Table : Emp
ID | Name | Salary
.........................................
4 | aa | 2000
2 | bb | 5000
1 | cc | 2000
3 | dd | 5000
how to select first and last Record?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Nov 28, 2014, 11:27 AM EST
Anthony Clarke4 reputationPosted Nov 28, 2014, 9:30 AM EST
AND
SELECT TOP 1 * FROM EMP Order BY ID desc
If you mean your first row is ID 4 and your last 3 then there is no way, you need to insert them into some form of order
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Nov 28, 2014, 6:34 PM EST
Best way as i think add a column said inserted date as DateTime and gets the last record and first record based on time. Make that columns default value GetDate(). So by default it will take system date