MySQL8.0----窗口函数

时间:2021-08-22 14:16:30   收藏:0   阅读:15

 

MySQL8.0窗口函数概述

1、聚合函数

select 
  name,
  salary,
department_id,
avg(salary) over()
from employee
where department_id  in (1,2,3);
SELECT
journey.id,
journey.date,
train.model,
train.max_speed,
MAX(max_speed) OVER(PARTITION BY route_id, date)
FROM journey
JOIN train
ON journey.train_id = train.id;

2、排序函数

格式:函数()over(order by XXX)

SELECT
name,
platform,
editor_rating,
RANK() OVER(ORDER BY editor_rating) as rank_
FROM game;
?

3、with函数

原文:https://www.cnblogs.com/2020-0309/p/15171795.html

评论(0)
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!