当前位置:网站首页>Working sql: it is required that the average number of awards cannot be displayed by ranking
Working sql: it is required that the average number of awards cannot be displayed by ranking
2022-07-18 00:46:00 【Little bigdata】
Work SQL:
demand :
| Teachers in the same department Average number of awards for teaching and research | Teachers with the same title Average number of awards for teaching and research | All the teachers in the school Average number of awards for teaching and research |
|---|---|---|
It is required that the average number of awards cannot be displayed by ranking
-- The number of teachers in this department who won the prize in teaching and research Change it to : Department ranking :5/145
select
RANK() OVER(partition by a.xymc ORDER BY JYHJCS desc) || '/' || b.num JSRS,
a.jzgh,
a.JYHJCS,
a.xymc
from
(
select
a.jzgh,
a.xymc,
sum(a.num) JYHJCS
from
(
-- huojiang list
select
count(distinct a.CGMC) num,
b.jzgh,
b.xymc
from
DC.jsx b
join
MODEL.hjmd a
on a.ZYWCR=b.jzgxm
where b.GWLX=' Full-time teacher '
group by b.jzgh,b.xymc
union all
-- Achievement Award
select
count(distinct a.CGMC) num,
b.jzgh,
b.xymc
from
DC.JSXXB b
join
MODEL.JXCGJ a
on a.HJZ=b.jzgxm
where b.GWLX=' Full-time teacher '
group by b.jzgh,b.xymc
) a
group by a.jzgh,a.xymc
) a
analysis
The original can be found by observation SQL / On the right is the total number of people in this department , Just add up all the winners in this department .
The modified SQL
select SUM(JYHJCS) nums,xymc from (
select
a.jzgh,
a.xymc,
sum(a.num) JYHJCS
from
(
-- Winning list
select
DECODE(count(distinct a.CGMC), null, 0,count(distinct a.CGMC)) num,
b.jzgh,
b.xymc
from
DC.JSXXB b
left join
MODEL.HJMD a
on a.ZYWCR=b.jzgxm
where b.GWLX=' Full-time teacher '
group by b.jzgh,b.xymc
expand
Teachers with the same title All the teachers in the school How to modify ??
边栏推荐
- [interview question] what is the difference between poll() and remove() in the queue
- This SQL will report an error when it is executed in pg. Oracle is OK
- Modern data stack: develop data efficiently and assist enterprise decision-making
- 1300_ Analysis of priority related knowledge points in FreeRTOS
- Basic theory of comprehensive evaluation
- MySQL advanced (III) summary of cursor simple knowledge points
- 【Jmeter】Win10 下载安装Jmeter 5.5
- Design of traffic light control system based on MCU
- The difference between observer mode and publish subscribe mode
- Prometheus operator deployment
猜你喜欢
![[tutorial] idea plug-in translation translation shortcut keys and translation settings](/img/26/7c200136a74ada6c065372412bfdba.png)
[tutorial] idea plug-in translation translation shortcut keys and translation settings

Why is there no Productism in Wei Lai?
![[mathematical modeling summer training] matlab drawing command](/img/a0/f4dd2496ac5bb702c822b23f360ab9.png)
[mathematical modeling summer training] matlab drawing command

MFC | untimely refresh of self drawn CStatic

【黄啊码】MySQL入门—3、我用select *,老板直接赶我坐火车回家去,买的还是站票

手把手教你用代码实现SSO单点登录

疑似被Apple招安,PlayCover作者删库跑路

Macm1 chip, centos8 virtual machine, mysql8 installation, service up, login error

Teach you how to use code to realize SSO single sign on

Basic use and tutorial of Charles
随机推荐
Q3 QmainWindow 状态栏 铆接部件 核心部件
Teach you how to use code to realize SSO single sign on
Using the idea shortcut key, you can know your technical level?
【源码】HashSet的实现原理
How to make a splash screen page
Getting started with jupyter notebook tutorial
034. Code rollback reset current branch to here
For 10 consecutive years, the "most commonly used" programming language for programmers ranked first is....
Communication chat system based on 51 single chip microcomputer
Uniapp+nodejs realize takeout app project 1- project introduction
蔚来缘何没有产品主义?
MFC file reading and writing based on a single document
Go1.18 upgrade function - Generic | go language from scratch
Why is there no Productism in Wei Lai?
Discussion on traversal order of complete knapsack in DP
语音聊天源码——语音聊天源码开发设计搭建
[source code] what is the difference between ArrayList and vector, and the difference of expansion multiple
Things about caching in software design
C language shift operation
spark调优(六):大家好才是真的好——广播变量