Sql Select 3 Columns And Dedupe On Two Columns
I have a job setup that currently selects records from a table that does not contain a unique index. I realize this could be solved by just putting an index on the table and the r
Solution 1:
You can use a GROUP BY and any aggregate function on the dateadded column to get unique author, pubdate results.
SELECT [author]
,[pubDate]
,MAX([dateadded])
FROM [Feeds].[dbo].[socialPosts]
WHERE CAST(FLOOR(CAST(dateadded AS float)) AS datetime) > dateadd(day,datediff(day, 0, getdate()-2), 0)
AND CAST(FLOOR(CAST(dateadded AS float)) AS datetime) < dateadd(day,datediff(day, 0, getDate()), 0)
GROUP BY
[author]
, [pubdate]
Post a Comment for "Sql Select 3 Columns And Dedupe On Two Columns"