How can I add a distinct to the following query :
SELECT TOP(30) X.ID ,ROW_NUMBER() OVER (ORDER BY Create DESC) AS LIMIT
FROM X INNER JOIN Y ON X.ID = Y.ID
as for now I get a lot of multiple records
Try something like this:
WITH CTE AS
(
SELECT DISTINCT TOP(30) X.ID, X.CREATE FROM X INNER JOIN Y ON X.ID = Y.ID
)
SELECT *, ROW_NUMBER() OVER (ORDER BY Create DESC) AS LIMIT
FROM CTE
You must insert CREATE in your query
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.