Hi,
I wonder if you could shed some light into this.
I have the following table.
Id, ContentId, VersionDate, ContentXml
There are several ContentIds in the table.
SELECT *
FROM tblVersions
WHERE (VersionDate =
(SELECT MAX(tblVersions2.VersionDate)
FROM tblContentVersion AS
tblVersions2
WHERE tblVersions2.ContentiD =
tblVersions.ContentiD))
ORDER BY ContentId
This query works to select the latest versions (MAX) of every content,
but I do not like it, any other way to do this properly?
I also want to do this knowing a set of ids (probably using IN )
SELECT *
FROM tblVersions
WHERE (VersionDate =
(SELECT MAX(tblVersions2.VersionDate)
FROM tblContentVersion AS
tblVersions2
WHERE tblVersions2.ContentiD =
tblVersions.ContentiD AND tblVersions.ContentiD IN (1, 2, 3, 6, 7, 8)
))
ORDER BY ContentId
Any ideas for improvements on this query?
ContentXml is of ntext type
Thanks,
/ jorge