So I’m looking to use a custom row cell to label my data.
Basketball | Baseball | Golf | Cost |
---|---|---|---|
1 | 0 | 0 | $50 |
0 | 1 | 0 | $75 |
1 | 0 | 1 | $150 |
0 | 1 | 1 | $225 |
The table I have is above. What I’m trying to do is below:
OUTPUT:
Sport | Cost |
---|---|
Basketball | 200 |
Baseball | 300 |
Golf | 375 |
I can get the sum of each sport but I’m having trouble making an alias for each sport on the output table (The first column)
How would I go about that? I’ve done an alias for a column header, but never for a row cell.
Thanks in advance!
2
Answers
Use a UNION with different WHERE conditions:
Fiddle