当前位置:网站首页>计算除去部门最高工资,和最低工资的平均工资(字节跳动面试)
计算除去部门最高工资,和最低工资的平均工资(字节跳动面试)
2022-07-15 23:22:00 【南湖渔歌】
计算除去部门最高工资,和最低工资的平均工资(字节跳动面试)
/* emp 表: id 员工 id ,deptno 部门编号,salary 工资 核心是使用窗口函数降序和升序分别排一遍就取出了最高和最低 其他延展: {规则:去掉两头的极端值}裁判最后计分、计算部门平均薪资、门店销售员的销售额等等场景 */
select deptno
,avg(salary) as daily_salary_avg
from
(
SELECT
dimShopID as deptno
,dimMemberID as id
,ROUND(SUM(AMT),0) AS salary
,rank()over(partition by dimShopID order by SUM(AMT)) as rank1
,rank()over(partition by dimShopID order by SUM(AMT) desc ) as rank2
FROM dw.fct_sales
WHERE dimDateID = '20170701'
and dimMemberID <> 0
GROUP BY dimShopID
,dimMemberID
HAVING SUM(AMT) > 300
) temp
where rank1 > 1 and rank2 >1
group by deptno;

边栏推荐
- The best time to buy and sell stocks
- Add / remove MySQL index stored procedure
- 剑指 Offer 64. 求 1 + 2 + … + n
- Issue record: “No thread for socket” about Memcached
- 第3章业务功能开发(导入市场活动,apache-poi)
- 基于Fitnesse的验收测试实验
- 编辑距离问题
- 实验五 图像分割与描述
- 数码管循环显示数字
- P1088 [noip2004 popularity group question 4] Martians ← next_ permutation
猜你喜欢
随机推荐
使用堆外内存
实验三 Servlet 相关技术
双线程猜数字
Experiment 4 image restoration and geometric correction
Pay attention to those potential system design problems
There is only one day left to prepare for the examination of Guangxi Second Construction Engineering Co., Ltd. the first three pages of the examination of second-class cost engineer came and raised sc
wireshark使用
实验四 Shell编程
Buckle practice - Top 18 K high-frequency elements
注册表实用技能【持续更新】
Breathing lamp circuit based on 555 timer
链表——反转链表
MGRE and GRE comprehensive experiment
没有sudo权限的情况下,如何在Ubuntu安装sqlite
编辑距离问题
mosquitto. H learning
Lombok 介绍
The digital tube displays numbers circularly
Pytorch分布式训练
C语言 sizeof 和strlen 的用法和区别









