Skip to content
Advertisement

SQL – Adding columns

I am new to SQL and was wondering if someone can help me with this small request. I am trying to have my output like down below:

enter image description here

But I am currently getting this output:

enter image description here

Here is my SQL code:

How can I get the columns to reflect MF, CH_A, CH_B, and CH_C with its respective value?

Advertisement

Answer

@Med2020 Your query should work fine. Please look into below example and let me know for which data it’s failing. I have changed the condition for M column.

Schema and insert statements:

Query:

Output:

MISTI M CH_A CH_B CH_C
TPA12 PROD PROD NM NM

db<fiddle here

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement