Umbraco v4~V6– Query history data by T-SQL

declare @nodeId int
set @nodeid = 1
select DENSE_Rank() OVER (PARTITION BY nodeid ORDER BY updateDate DESC) AS versionNum
, published
, documentUser
, text as 'Name'
, templateId
, cmsdocument.alias
, newest
, PropertytypeId
, cmsPropertyType.Name as 'Propertytype Name'
, dataInt
, cmsPropertyType.Alias as 'Propertytype Alias'
, dataInt
, dataDate
, dataNvarchar
, dataNtext
, updateDate
, releaseDate
, [ExpireDate]
from cmsdocument
left join cmsPropertyData on cmsdocument.versionid = cmsPropertyData.versionid
left join cmsPropertyType on cmsPropertyData.propertytypeid = cmsPropertyType.id
where nodeid = @nodeid