Stanislav Jirák Stanislav Jirák -4 years ago 100
SQL Question

How do I retrieve last record from a table in SQL?

Since function LAST() works only MS Access...
SQL Server Management Studio.

Answer Source
--An Example to retrieve last record from a table in SQL
WIth Cte_1(id ,date,price)
AS
(
SELECT 1  , '1999-01-01',10      Union ALl
SELECT 2  , '1999-01-01',10      Union ALl
SELECT 3  , '2000-02-02',15      Union ALl
SELECT 4  , '2011-03-03',15      Union ALl
SELECT 5  , '2011-04-04',16      Union ALl
SELECT 6  , '2011-04-04',20      Union ALl
SELECT 7  , '2017-08-15',20
)
SELECT Top 1 * from
Cte_1 A Order By 1 Desc
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download