WITH cte_MyCTE AS ( SELECT tbl1.[MyPID], tbl1.[MyDate], tbl2.[MyNumber], tbl2.[MyOtherNumber], DENSE_RANK() OVER(ORDER BY tbl1.[MyPID], tbl1.[MyNumber], DATEADD(HOUR, (DATEDIFF(HOUR, '1900-01-01 00:00:00.000', tbl1.[MyDate]/3)*3, '1900-01-01 00:00:00.000')) AS [MyGrpID] FROM Table1 AS tbl1 LEFT JOIN Table2 AS tbl2 ) INSERT INTO Table3 SELECT DISTINCT [MyGrpID], [MyPID], [MyNumber], [MyOtherNumber] FROM cte_MyCTE
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.