分析函数应用: 1、 结构:聚合函数()over( partition by 字段1,字段2,字段3 order by 字段 desc/asc range between 数值/date preceding/flowing and 数值/date preceding/flowing) 聚合函数可以是:sum,count,avg,max,min,first_value,last_value,rank,dense_rank ,row_number, ratio_to_report Over不能单独
--高级查询在数据库中用得是最频繁的,也是应用最广泛的。 Ø 基本常用查询 --select select * from student; --all 查询所有 select all sex from student; --distinct 过滤重复 select distinct sex from student; --count 统计 select count(*) from student; select count(sex) from student; select count(dis
与over函数结合的几个函数介绍 Row_number() over()、rank() over()和dense_rank()over()函数的使用 Select * from (select name,class,s,rank() over(partition by class order by s desc) mm from t2) where mm=1; 说明: 1.在求第一名成绩的时候,不能用row_number(),因为如果同班有2个并列第1,row_number()只返回一个结果;