Forum Discussion

Scorpion_S1's avatar
Scorpion_S1
Copper Contributor
Apr 02, 2024
Solved

SQL rows to collumns

Hi everyone, I need your help. I have a view that's return the result in this format: but I need to have an output like this:  Does anyone have an idea on how to do it? Thanks  
  • Arshad440's avatar
    Apr 03, 2024
    hi,
    You can use this Query

    SELECT Cod,ISNULL(ABF,0) ABF,ISNULL(SCA,0) SCA,ISNULL(SCC,0) SCC, ISNULL(MTV,0) MTV,ISNULL(PCP,0) PCP,ISNULL(SDT,0) SDT
    FROM <YouTableName>
    PIVOT
    (
    MAX(value) FOR Name in([ABF],[SCA],[SCC],[MTV],[PCP],[SDT])
    )
    as PivotTable



    hope it'll work
    Thanks

Resources