• 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)
    世界上最美的风景,是自己努力的模样
  • 相关阅读:
    jq 的简单循环
    简单的下拉菜单
    jQ事件
    图片移动
    选中效果
    js 时间
    简单的密码验证
    DOM 的简介 和一些方法
    Java编程思想笔记
    Java并发笔记(二)
  • 原文地址:https://www.cnblogs.com/xiong-hua/p/15108397.html
Copyright © 2020-2023  润新知