I am using the following stored procedure to get the newest date out of a column which works fine.
Can someone tell me how I have to amend this that I also get the rest of the data of this record selected (i.e. the one with the max date) ?
The column in question is called "updated" and is formatted as datetime so the values there should be unique.
Example:
The max value for column "updated" is the row with "itemID" = 3.
In this case I also want the rest of the data in this row selected, say the columns are called col1, col2, col3, col4 + the column "updated".
My stored procedure:
SET NOCOUNT ON;
SELECT CONVERT(VARCHAR(11), MAX(updated), 106) AS lastUpdated
FROM MeetingDetails
WHERE itemStatus = 'active'
FOR XML PATH('updates'), ELEMENTS, TYPE, ROOT('root')
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…