|
| 1 | +# Time: O(n) |
| 2 | +# Space: O(n) |
| 3 | + |
| 4 | +SELECT id, |
| 5 | + SUM(IF(month = 'Jan', revenue, NULL)) AS Jan_Revenue, |
| 6 | + SUM(IF(month = 'Feb', revenue, NULL)) AS Feb_Revenue, |
| 7 | + SUM(IF(month = 'Mar', revenue, NULL)) AS Mar_Revenue, |
| 8 | + SUM(IF(month = 'Apr', revenue, NULL)) AS Apr_Revenue, |
| 9 | + SUM(IF(month = 'May', revenue, NULL)) AS May_Revenue, |
| 10 | + SUM(IF(month = 'Jun', revenue, NULL)) AS Jun_Revenue, |
| 11 | + SUM(IF(month = 'Jul', revenue, NULL)) AS Jul_Revenue, |
| 12 | + SUM(IF(month = 'Aug', revenue, NULL)) AS Aug_Revenue, |
| 13 | + SUM(IF(month = 'Sep', revenue, NULL)) AS Sep_Revenue, |
| 14 | + SUM(IF(month = 'Oct', revenue, NULL)) AS Oct_Revenue, |
| 15 | + SUM(IF(month = 'Nov', revenue, NULL)) AS Nov_Revenue, |
| 16 | + SUM(IF(month = 'Dec', revenue, NULL)) AS Dec_Revenue |
| 17 | +FROM department |
| 18 | +GROUP BY id; |
0 commit comments