SELECT id,
itemid,
'' AS Language,
fieldid,
value,
created,
updated
FROM dbo.sharedfields WITH (nolock)
UNION ALL
SELECT id,
itemid,
language,
fieldid,
value,
created,
updated
FROM dbo.unversionedfields WITH (nolock)
UNION ALL
SELECT dbo.versionedfields.id,
dbo.versionedfields.itemid,
dbo.versionedfields.language,
dbo.versionedfields.fieldid,
dbo.versionedfields.value,
dbo.versionedfields.created,
dbo.versionedfields.updated
FROM dbo.versionedfields WITH (nolock)
INNER JOIN (SELECT itemid,
language,
Max(version) AS Version
FROM dbo.versionedfields AS VersionedFields_1 WITH (nolock)
GROUP BY itemid,
language) AS b
ON dbo.versionedfields.itemid = b.itemid
AND dbo.versionedfields.language = b.language
AND dbo.versionedfields.version = b.version
No comments:
Post a Comment