0

This is what my data looks like:

## ID ## ## Phase ## ## Phase Datet ## ## Phase Temp ## ## TempRecorded ##
23300200    Induction   2016-10-07        30               2016-10-07
23300200    Maintenance 2016-10-07        35               2016-10-07
23300200    Rewarming   2016-10-07        35.5             2016-10-07  

I want to have it look like this:

## ID ## ## Induction Phase ## ## Induction Phase Datet ## ## Induction Phase Temp ## ## Induction TempRecorded ## ## ID ## ## Maintenance Phase ## ## Maintenance Phase Datet ## ## Maintenance Phase Temp ## ## Maintenance TempRecorded ##
23300200    Induction                    2016-10-07                   30                     2016-10-07                          Maintenance                2016-10-07                  35                              2016-10-07 
  • check [PIVOT](https://technet.microsoft.com/es-es/library/ms177410(v=sql.105).aspx) – Juan Carlos Oropeza Oct 21 '16 at 16:48
  • Good luck with that. SO contributors are not a code writing service. Show effort. Provide code that you have tried. List errors you encountered, or hire someone to write this for you. – S3S Oct 21 '16 at 16:49
  • As a starter pointer you will need to pivot on each of the Phase values. As you then have multiple values per phase and want them separately, you might want to consider how you can expand the Pivot further to include multiple column values. – LogicalMan Oct 21 '16 at 17:32

1 Answers1

0

My colleague provided me with a solution

SELECT I.*, M.*,R.*
FROM
(select * from #PhaseTemp where ValueText = 'Induction') I
LEFT JOIN (select * from #PhaseTemp where ValueText = 'Maintenance') M ON M.ClientGUID = I.ClientGUID
LEFT JOIN (select * from #PhaseTemp where ValueText = 'Rewarming') R ON R.CLIENTGUID = I.CLIENTGUID