This refers to another question that I asked earlier. You might be better off understanding this if you quickly look through it.
Version numbers are floating, decimal, or double
I have two columns and a stranger in the database table. A [Version] and the [Revision] column . They relate to version numbers. e.g. Version 1, version 2 = v1.2
What I need to do is to capture the maximum version number for a specific foreign key.
Here is what I still have:
SELECT f.[pkFileID]
,x.[fkDocumentHeaderID]
,f.[fkDocumentID]
,x.[Version]
,x.[Revision]
,f.[FileURL]
,f.[UploadedBy]
,f.[UploadedDate]
FROM
(
SELECT
docs.[fkDocumentHeaderID]
,MAX([Version]) AS Version
,MAX([Revision]) AS Revision
FROM
[ClinicalGuidanceV2].[dbo].[tbl_DocumentFiles]
INNER JOIN
dbo.tbl_Documents docs ON [fkDocumentID] = [pkDocumentID]
GROUP BY
docs.[fkDocumentHeaderID]
)
AS x
INNER JOIN
dbo.tbl_DocumentFiles f ON
f.[fkDocumentHeaderID] = x.[fkDocumentHeaderID] AND
f.[Version] = x.[Version] AND
f.[Revision] = x.[Revision]
. obvisouly , , 1.1, 1.2 2.0, , , 2.2 ( ).
( ), [], [] [], , .
, , .
.