﻿SELECT LatestVersionHistoryID
	FROM
	(
		SELECT MAX(VersionHistoryID) OVER (PARTITION BY DocumentID) AS LatestVersionHistoryID
			FROM CMS_VersionHistory
	) AS LatestVersionHistoryIDs
	GROUP BY LatestVersionHistoryID
﻿SELECT LatestVersionHistoryID
	FROM
	(
		SELECT MAX(VersionHistoryID) OVER (PARTITION BY DocumentID) AS LatestVersionHistoryID
			FROM CMS_VersionHistory
			WHERE WasPublishedFrom IS NOT NULL
	) AS LatestVersionHistoryIDs
	GROUP BY LatestVersionHistoryID
Update latest version history to filter out draft versions
Update latest version history to filter out draft versions
