I want to return the date and ID for the latest added record in on of our tables.
can anyone suggest right query for that plz. We are using sqlServer
SELECT [BGArx_ID], [BGArx_PUBLISHED_DATE]
FROM TECH_ARTICLES
WHERE [BGArx_PUBLISHED_DATE] = ???
Use the ORDER BY clause to sort by the newest record and then limit the query to return just one result.
EDIT (marc_s)
for SQL Server, which doesn’t know the
LIMITkeyword, you’d need to useTOP 1in the select instead: