sql server select last row code example
Example 1: how to get last row of table in sql
mysql> select *from getLastRecord ORDER BY id DESC LIMIT 1;
Example 2: Select last row from SQL Table
SELECT * FROM TableName WHERE id=(SELECT max(id) FROM TableName);
Example 3: select first and last row sql
select
(select <some_column> from <some_table>
order by <some_field> limit 1) as oldest,
(select <some_column> from <some_table>
order by <some_field> desc limit 1) as newest
;