使用Row_Number()取出第一条数据

(SELECT * 
  FROM (SELECT ROW_NUMBER() OVER (PARTITION BY MachineId ORDER BY ReportDateTime DESC) RowNum, 
        dbo.MachineFault.* 
        FROM dbo.MachineFault ) 
        AS t1 
  WHERE   RowNum = 1 )
  AS ReportTable

你可能感兴趣的:(使用Row_Number()取出第一条数据)