I am trying to achieve the dynamic header based on the column value.
This is the original table. I want to prompt it
The type value will decide what the column header would be.
Would you please drop some hints about how to do it in SQL
I am trying to achieve the dynamic header based on the column value.
This is the original table. I want to prompt it
The type value will decide what the column header would be.
Would you please drop some hints about how to do it in SQL
Use aggregates and expressions:
SELECT id,
SUM(CASE WHEN type = 'secure' THEN level ELSE 0 END) AS secure_level,
SUM(CASE WHEN type = 'hazard' THEN level ELSE 0 END) AS hazard_level,
FROM original_table
GROUP BY id