views:

56

answers:

1

How to retreive the last row of a table which doesn't has any unique id like

select * from sample where id=(select max(id) from sample)
+5  A: 
select TOP 1 * from sample order by whatever DESC

There must be some sort (ORDER BY) criteria to define the last row, otherwise your request makes no sense. For example, the last row based on AddedDateTime column in the product table

select TOP 1 * from product order by AddedDateTime DESC
gbn