select id = messageID,
starred = case starred when 1 then 'starred' else 'not starred' end,
[from] = displayName,
subject = msgSubject,
[date] = sentDate,
beenRead = case beenRead when 1 then '1' else '0' end
from tblMessages m
inner join tblUsers u on m.msgFrom = u.userID and u.status = 1
where msgTo = 100 and
to_deleteDate is null
order by sentDate DESC
Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.
TRUSTED BY
ASKER
This mostly worked, I only had to change
row_number() over (partition by messageID order by sentDate desc) idx
to
row_number() over (partition by conversationID order by sentDate desc) idx
to get the data I wanted. Thanks again!