This is my current SQL query:
SELECT
ROW_NUMBER() OVER(PARTITION BY [Machine_ID] ORDER BY Version DESC) AS ROW,
MachineList.*
FROM
MachineList
Basically, I want to get distinct machine information. If several machines have the same ID
, then choose the one with latest version.
However, SQL Server 2000 does not support the ROW_Number
function. Is there any alternative for the SQL above?
P.S. most solutions I found on line are using temp table. But I could not use temp table because this query will be used in SSIS.
select m.*
from machinelist as m
inner join (
select
t.machine_id, max(t.version) as version
from machinelist as t
group by t.machine_id
) as mm on
mm.machine_id = m.machine_id and mm.version = m.version