magritton
12/24/2014 - 3:01 PM

This snippet get a distinct row of information from SQL server using the with operator to store a temporary table and then getting the rakin

This snippet get a distinct row of information from SQL server using the with operator to store a temporary table and then getting the raking where it equals to 1

with TT as(SELECT 
[Process]
      ,[StartTime]
      ,[EndTime]
      ,[Status]
      ,[Note]
      ,[CallingDevice],
	  RANK() over(partition by [Process] ORDER BY [StartTime] DESC) as R
  FROM [OPWBI].[dbo].[Automated_Process_Tracker])
  SELECT * FROM TT
  WHERE TT.R = 1