Q: SQL - select IDs that have been seen in table w/ timestamp <= 1+ year I have a table with user IDs, timestamps, and sales info. The same user IDs appear multiple times in the data (every time they purchase). I only want to select the user IDs that have shown up in the table for at least a year (so, for the sake of simplicity I'll do a timestamp less than "12-31-2016"). How can I write this with SQL?

A: Try this:
Select Distinct userID
FROM Table
WHERE DATEDIFF(yy,cast(Timestamp as date),getdate())>=1

Updated based on your comment:
Select Distinct userID
FROM Table
WHERE CAST(Timestamp as date)>'20161231'

