Avatar of huang_ck
huang_ck

asked on 

sql server query to select the latest records with distinct

I have a sql server query:

SELECT DISTINCT
                          image_id, id, diy_variables, publish, upload_date, frame, member_id
FROM            table1
ORDER BY id DESC

I need to select the latest 10 records and I tried:
SELECT TOP 10 (DISTINCT image_id, id, diy_variables, publish, upload_date, frame, member_id) .....
SELECT TOP 10 DISTINCT image_id, id, diy_variables, publish, upload_date, frame, member_id .....

both doesnt work, what is the correct syntax to do so? Isn't it something like SELECT TOP 10 * ......
Microsoft SQL Server

Avatar of undefined
Last Comment
huang_ck

8/22/2022 - Mon