Here is the syntax to get the last 5 records of the table in SQL:
SELECT * FROM
(SELECT TOP 5 *
FROM table_name
ORDER BY ID DESC
)
ORDER BY id ASC;
In the above query, we used subquery with the TOP clause that returns the table with the last 5 records sorted by ID in descending order. Again, we used to order by clause to sort the result-set of the subquery in ascending order by the ID column.
If you want to take a course that can provide Instructor-led training and certification, I suggest this SQL Training by Intellipaat.