当前位置:网站首页>牛客网数据库SQL实战详细剖析(26-30)
牛客网数据库SQL实战详细剖析(26-30)
2022-04-23 14:48:00 【游戏编程】
SQL26 汇总各个部门当前员工的title类型的分配数目
select de.dept_no, d.dept_name, t.title, count(*)from departments as d right join dept_emp as de on de.dept_no=d.dept_noleft join titles as t on de.emp_no=t.emp_nogroup by de.dept_no,d.dept_name,t.titleorder by de.dept_no,t.title
解题思路: 重点理解各个部门下各个title类型的汇总。
①先以员工编号为联结条件联结titles表和dept_emp表,得到员工部门编号和员工对应的title类型,再以部门编号为联结条件联结departments表,得到部门名称,最后记得限定titles表和dept_emp表的时间为当前to_date ='9999-01-01'。
②汇总的是各个部门下各个title类型,所以要先将部门编号进行一次汇总,再将tltle类型进行汇总,聚合函数count的参数为title。
SQL29 使用join查询方式找出没有分类的电影id
select f.film_id, f.titlefrom film fleft join film_category fc on f.film_id = fc.film_id where fc.category_id is null
解题思路: 使用film表为主表,左联结film_category表,限定条件为分类id为空的记录。
SQL30 使用子查询的方式找出属于Action分类的所有电影对应的title,description
select fi.title, fi.description from film fi where fi.film_id in ( select f.film_id from film_category f where f.category_id = ( select category_id from category where name = 'Action' ) )
解题思路: 使用两次子查询(子查询内嵌套子查询),通过IN谓词,film_id,category_id,将三个表层层嵌套查询。
作者:酱饼
游戏编程 ️,一个游戏开发收藏夹~
如果图片长时间未显示,请使用Chrome内核浏览器。
版权声明
本文为[游戏编程]所创,转载请带上原文链接,感谢
https://www.233tw.com/database/118804
边栏推荐
- 多语言通信基础 06 go实现grpc的四种数据流模式实现
- Pnpm installation and use
- Programming philosophy - automatic loading, dependency injection and control inversion
- [jz46 translate numbers into strings]
- 面试官:说一下类加载的过程以及类加载的机制(双亲委派机制)
- Proteus simulation design of four storey and eight storey elevator control system, 51 single chip microcomputer, with simulation and keil c code
- Parameter stack pressing problem of C language in structure parameter transmission
- 【Servlet】Servlet 详解(使用+原理)
- Detailed comparison between asemi three-phase rectifier bridge and single-phase rectifier bridge
- Realization of four data flow modes of grpc based on Multilingual Communication
猜你喜欢

利用 MATLAB 编程实现最速下降法求解无约束最优化问题

交通灯系统51单片机设计(附Proteus仿真、C程序、原理图及PCB、论文等全套资料)

Using MATLAB programming to realize the steepest descent method to solve unconstrained optimization problems

Proteus simulation design of DC adjustable regulated power supply (with simulation + paper and other data)

电容

1 minute to understand the execution process and permanently master the for cycle (with for cycle cases)

Want to be an architect? Tamping the foundation is the most important

Arduino for esp8266串口功能简介

Explain TCP's three handshakes in detail

8.4 循环神经网络从零实现
随机推荐
如何打开Win10启动文件夹?
Parameter stack pressing problem of C language in structure parameter transmission
[untitled]
UML项目实例——抖音的UML图描述
Thread synchronization, life cycle
Mq-2 and DS18B20 fire temperature smoke alarm system design, 51 single chip microcomputer, with simulation, C code, schematic diagram, PCB, etc
面试官:说一下类加载的过程以及类加载的机制(双亲委派机制)
Electronic perpetual calendar of DS1302_ 51 single chip microcomputer, month, day, week, hour, minute and second, lunar calendar and temperature, with alarm clock and complete set of data
Detailed explanation of C language P2 selection branch statement
Matrix exchange row and column
Detailed explanation of C language knowledge points -- first knowledge of C language [1]
QT Detailed explanation of pro file
I thought I could lie down and enter Huawei, but I was confused when I received JD / didi / iqiyi offers one after another
ASEMI整流模块MDQ100-16在智能开关电源中的作用
Detailed comparison between asemi three-phase rectifier bridge and single-phase rectifier bridge
SHT11传感器的温度湿度监控报警系统单片机Proteus设计(附仿真+论文+程序等)
在游戏世界组建一支AI团队,超参数的多智能体「大乱斗」开赛
The initial C language framework is suitable for review and preliminary understanding
交通灯系统51单片机设计(附Proteus仿真、C程序、原理图及PCB、论文等全套资料)
ASEMI三相整流桥和单相整流桥的详细对比