I'm trying to find unique User Id's with and associated Media Id.
Here is what I have:
Select UserId, (Select Top(1) MediaId From Media Where UserId = M.UserId ORder By NewId()) as MediaId From Media as M Group By UserId
I tried different group by combinations, but none of them worked.
Is there a better way to do this?
Edit
The table looks like this:
MediaId int PK
UserId int FK
Status nvarchar(50)
Expected results
UserId MediaId
9 101
10 234