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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Manish Kumar ChoudharyPosted Nov 28, 2014, 11:34 PM
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 dateVulpesPosted Nov 28, 2014, 4:27 PM
Anthony ClarkePosted Nov 28, 2014, 2:30 PM
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