1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
SELECT id, SUM(if (MONTH = 'Jan', revenue, NULL)) AS 'Jan_Revenue', SUM(if (MONTH = 'Feb', revenue, NULL)) AS 'Feb_Revenue', SUM(if (MONTH = 'Mar', revenue, NULL)) AS 'Mar_Revenue', SUM(if (MONTH = 'Apr', revenue, NULL)) AS 'Apr_Revenue', SUM(if (MONTH = 'May', revenue, NULL)) AS 'May_Revenue', SUM(if (MONTH = 'Jun', revenue, NULL)) AS 'Jun_Revenue', SUM(if (MONTH = 'Jul', revenue, NULL)) AS 'Jul_Revenue', SUM(if (MONTH = 'Aug', revenue, NULL)) AS 'Aug_Revenue', SUM(if (MONTH = 'Sep', revenue, NULL)) AS 'Sep_Revenue', SUM(if (MONTH = 'Oct', revenue, NULL)) AS 'Oct_Revenue', SUM(if (MONTH = 'Nov', revenue, NULL)) AS 'Nov_Revenue', SUM(if (MONTH = 'Dec', revenue, NULL)) AS 'Dec_Revenue' FROM Department GROUP BY id;
|