-1

I am selecting PatientID, Location, LN, FN, ServiceCode1, ServiceDate1, ServiceCode2, ServiceDate2 from a table. I am trying to list each service and corresponding date as its own row. The attached image shows how I want this to look highlighted in green. I've tried using the PIVOT function but with no luck. ColumnToRow

Chris
  • 323
  • 5
  • 21

1 Answers1

1

With the help of a Cross Join

Select  A.PatientID
       ,A.Location
       ,A.Last_Name
       ,A.First_Name
       ,B.*
 From  YourTable A
 Cross Join (
              Values ('Service_Code1',A.Service_Date1)
                    ,('Service_Code2',A.Service_Date2)
            ) B  (Service_Code,Service_Date)  
John Cappelletti
  • 79,615
  • 7
  • 44
  • 66