1.from
2.join on 或 lateral view explode(需炸裂的列) tbl as 炸裂后的列名
3.where
4.group by (开始使用select中的别名,从group 开始往后都可用)
5.聚合函数 如Sum() avg() count(1)等
6.having
7.select 中若包含over()开窗函数,执行完非开窗函数后select等待执行完开窗函数,然后执行select完,开窗函数通过表数据进行分区和排序,跟select查询中的字段是平行关系,不依赖查询字段。
8.distinct
9.distribute by /cluster by
10. sort by
11.order by
12.limit
13.union /union all
本文深入探讨了SQL查询的各个关键步骤,包括from、join、where、groupby、聚合函数、having、select中的开窗函数、distinct、distributeby/clusterby、sortby、orderby、limit以及union/unionall的用法。通过实例解析,帮助读者掌握SQL在数据处理中的高效运用,提升数据查询和分析能力。
2169

被折叠的 条评论
为什么被折叠?



