group by grouping sets 的用法
SELECT country, null department, round(avg(salary), 2) FROM employee1 GROUP BY country UNION ALL SELECT null country, department, round(avg(salary), 2) FROM employee1 GROUP BY department; 等价于 SELECT country, department, round(avg(salary), 2) FROM employee1 GROUP BY GROUPING SETS (country, department); GROUP BY GROUPING SETS (A,B,C) 等价与 GROUP BY A UNION ALL GROUP BY B UNION ALL GROUP BY C GROUP BY GROUPING SETS ((A,B,C)) 等价与 GROUP BY A,B,C GROUP BY GROUPING SETS (A,(B,C)) 等价与 GROUP BY A UNION ALL GROUP BY B,C GROUP BY GROUPING SETS (A) 等价于 GROUP BY A,B,C ,GROUPING SETS (B) ,GROUPING SETS (C) GROUP BY GROUPING SETS (A) 等价于 GROUP BY A,B,C ,GROUPING SETS ((B,C)) GROUP BY GROUPING SETS (A) 等价于 GROUP BY A,B ,GROUPING SETS (B,C) UNION ALL GROUP BY A,C GROUP BY A 等价于 GROUP BY A ,B ,B ,GROUPING SETS ((B,C)) ,C GROUP BY A 等价于 GROUP BY A,B,C ,B UNION ALL ,GROUPING SETS (B,C) GROUP BY A,B GROUP BY A 等价于 GROUP BY A,B,C ,B UNION ALL ,C GROUP BY A,B,C ,GROUPING SETS (B,C)
世界上最美的风景,是自己努力的模样