I have a table called DiagnosisList, which contains following fields and sample data. I need to switch the DiagnosisCodes, DiagnosisDescriptions and DiagCodeTypes into one row per Identifier.
I was trying to use the following case when statement, but that causes NULL values when there is more than one result for an Identifier. In the example below, I need the data in row 6 to move up to row 5:
select Identifier, case when Dx# = '1' then DiagnosisCode end as DxCode1,
case when Dx# = '1' then DiagnosisDescription end as DxDescription1,
case when Dx# = '1' then DiagCodeType end as DxType1,
case when Dx# = '2' then DiagnosisCode end as DxCode2,
case when Dx# = '2' then DiagnosisDescription end as DxDescription2,
case when Dx# = '2' then DiagCodeType end as DxType2
from DiagnosisList
Any assistance would be greatly appreciated!