SELECT v.DoorNo,v.NewDoorNo, v.GarageName, c.VersionDate, v.OperatorName as Operator, v.OperatorId, c.DeviceId, c.VehicleId, c.ProgramVersionNo,
c.ParameterFileVersionNo, c.TariffFileVersionNo, c.BlaclistFileVersionNo, c.LineNoFileVersionNo, c.ScreenProgramVersion,
c.SoapProgramVersiyon
FROM dbo.vValidator AS v RIGHT JOIN
dbo.CDeviceVersion AS c with(nolock) ON (v.DoorNo = c.DoorNo
or v.NewDoorNo=c.DoorNo
where v.NewDoorNo='O1211'
此查询返回2行,但我想只选择一行具有最大版本日期。我该如何选择它?
答案 0 :(得分:0)
这是你想要的吗?
SELECT TOP (1) v.DoorNo,v.NewDoorNo, v.GarageName, c.VersionDate, v.OperatorName as Operator, v.OperatorId, c.DeviceId, c.VehicleId, c.ProgramVersionNo,
c.ParameterFileVersionNo, c.TariffFileVersionNo, c.BlaclistFileVersionNo, c.LineNoFileVersionNo, c.ScreenProgramVersion,
c.SoapProgramVersiyon
FROM dbo.vValidator AS v RIGHT JOIN
dbo.CDeviceVersion AS c with(nolock) ON (v.DoorNo = c.DoorNo
or v.NewDoorNo=c.DoorNo)
where v.NewDoorNo='O1211'
ORDER BY c.VersionDate