I have a table (Damage) structure of the following type
Rowid damageTypeACount damageTypeBCount damageTypeCCount
1 23 44 33
And also I have a requirement to read these table rows with result as ( title, id are set manually), sort of making transposing to columns to rows but with additional properties
id damagecountsum label
1 23 Damage Type A
2 44 Damage Type B
3 33 Damage Type C
I did the following query and it works but wondering if there is a better way
SELECT 1 as id,
damageTypeACount as damagecount,
"Damage Type A Count" as label
FROM Damage where rowId=1
UNION ALL
SELECT 2 as id,
damageTypeBCount as damagecount,
"Damage Type B Count" as label
FROM Damage where rowId=1
UNION ALL
SELECT 3 as id,
damageTypeCCount as damagecount,
"Damage Type C Count" as label
FROM Damage where rowId=1
The above query works as expected but I was wondering if it is possible to do this in a single select statement transposing the columns into rows