SQL Server - how to delete last three record from the table using simple sql query
Asked By aman on 02-Nov-11 08:08 AM
i want to delete a record from the table but i want to delte the last three record from the table.
please help me.
Rohan Dave replied to aman on 02-Nov-11 08:14 AM
you can use below query ...
delete top 3 from yourtable order by id desc
Riley K replied to aman on 02-Nov-11 08:16 AM
Use this query
delete from orders
where orderid in (select top 3 orderid from orders order by orderid desc)
Kirtan Patel replied to aman on 02-Nov-11 08:20 AM
Try this Query
Suchit shah replied to aman on 02-Nov-11 08:25 AM
u can do it like below query
delete from tablename where Fieldname in ( select Top 3 Fieldname from tablename order by fieldname)
Reena Jain replied to aman on 02-Nov-11 09:35 AM
try this and let me know
aneesa replied to aman on 02-Nov-11 01:12 PM
*, ROW_NUMBER() OVER(
RowNum <= 3;