当前位置:网站首页>Detailed analysis of SQL combat of Niuke database (26-30)
Detailed analysis of SQL combat of Niuke database (26-30)
2022-04-23 14:53:00 【Game programming】
SQL26 Summarize the current employees of each department title Number of assignments of type
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
Their thinking : Focus on understanding each department title Summary of types .
① First, take the employee number as the connection condition titles Table and dept_emp surface , Get the employee's department number and the employee's corresponding title type , Then take the department number as the connection condition departments surface , Get the Department name , Finally, remember to limit titles Table and dept_emp The time of the table is the current to_date ='9999-01-01'.
② The summary refers to all... Under each department title type , Therefore, the department number should be summarized first , then tltle Summary by type , Aggregate functions count The parameters for title.
SQL29 Use join Search to find movies without classification 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
Their thinking : Use film Table is given priority to , Left link film_category surface , The limiting condition is classification id Empty record .
SQL30 Use a subquery to find out what belongs to Action All movies in the category correspond to 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' ) )
Their thinking : Use subqueries twice ( Subquery nested subquery ), adopt IN The predicate ,film_id,category_id, Nest the three tables layer by layer to query .
author : Sauce cake
Game programming ️, A game development favorite ~
If the picture is not displayed for a long time , Please use Chrome Kernel browser .
版权声明
本文为[Game programming]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231447589868.html
边栏推荐
- Contraction mapping theorem
- Alexnet model
- Mds55-16-asemi rectifier module mds55-16
- thinkphp5+数据大屏展示效果
- 1-初识Go语言
- LeetCode153-寻找旋转排序数组中的最小值-数组-二分查找
- Practice of unified storage technology of oppo data Lake
- 编程哲学——自动加载、依赖注入与控制反转
- Leetcode153 - find the minimum value in the rotation sort array - array - binary search
- The difference between having and where in SQL
猜你喜欢
编程哲学——自动加载、依赖注入与控制反转
What is the main purpose of PCIe X1 slot?
capacitance
[stc8g2k64s4] introduction of comparator and sample program of comparator power down detection
Leetcode exercise - 396 Rotation function
Sword finger offer II 019 Delete at most one character to get palindrome (simple)
Ali developed three sides, and the interviewer's set of combined punches made me confused on the spot
Want to be an architect? Tamping the foundation is the most important
eolink 如何助力远程办公
免费在upic中设置OneDrive或Google Drive作为图床
随机推荐
DVWA之暴力破解(Brute Force)Low-->high
What is the effect of Zhongfu Jinshi wealth class 29800? Walk with professional investors to make investment easier
SVN详细使用教程
封面和标题中的关键词怎么写?做自媒体为什么视频没有播放量
1N5408-ASEMI整流二极管1N5408
SQLSERVER事物与锁的问题
冰冰学习笔记:一步一步带你实现顺序表
Redis主从同步
Leetcode153 - find the minimum value in the rotation sort array - array - binary search
压缩映射定理
免费在upic中设置OneDrive或Google Drive作为图床
1-初识Go语言
中富金石财富班29800效果如何?与专业投资者同行让投资更简单
Programming philosophy - automatic loading, dependency injection and control inversion
你还不知道责任链模式的使用场景吗?
How do I open the win10 startup folder?
大文件如何快速上传?
PCIe X1 插槽的主要用途是什么?
Leetcode exercise - 396 Rotation function
The art of automation