Click here to Skip to main content
15,886,095 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
8/4/2014 1:00:00 PM English P
8/4/2014 10:00:00 AM Maths A
8/7/2014 10:00:00 AM Maths P
8/8/2014 10:00:00 AM Maths P
8/5/2014 10:00:00 AM Maths P


This is my table. Suppose I want to find out 5 records which was inserted recently. I also want to find it out on the basis of time. Then how to write a SQL query to retrieve data?
Posted

1 solution

Try:
SQL
SELECT TOP 5 * FROM MyTable ORDER BY DateColumn DESC
 
Share this answer
 
Comments
VICK 11-Aug-14 4:43am    
Perfecto. My 5+.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900