sql - How to get last inserted row from table? -
my table below:
id data date abc 2016-10-01 00:00:00 def 2015-05-20 00:00:00 b xyz 2014-05-20 00:00:00 b uvw 2016-10-01 00:00:00 b rst 2015-10-01 00:00:00
i need last inserted row column id. expected output be:
id data date def 2015-05-20 00:00:00 b rst 2015-10-01 00:00:00
i can able last inserted row identity column or inserted date column if have. how last inserted row without these columns?
row_number()
typical way of doing this:
select t.* (select t.*, row_number() on (partition id order date desc) seqnum t ) t seqnum = 1;
Comments
Post a Comment