当前位置:网站首页>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
边栏推荐
猜你喜欢
8.3 语言模型与数据集
Want to be an architect? Tamping the foundation is the most important
Role of asemi rectifier module mdq100-16 in intelligent switching power supply
Explain TCP's three handshakes in detail
每日一题-LeetCode396-旋转函数-递推
8.4 循环神经网络从零实现
Model location setting in GIS data processing -cesium
[untitled]
《JVM系列》 第七章 -- 字节码执行引擎
你還不知道責任鏈模式的使用場景嗎?
随机推荐
1 - first knowledge of go language
LeetCode153-寻找旋转排序数组中的最小值-数组-二分查找
Arduino for esp8266串口功能简介
帧同步 实现
Provided by Chengdu control panel design_ It's detailed_ Introduction to the definition, compilation and quotation of single chip microcomputer program header file
One of the advanced applications of I / O reuse: non blocking connect -- implemented using select (or poll)
填充每个节点的下一个右侧节点指针 II [经典层次遍历 | 视为链表 ]
Programming philosophy - automatic loading, dependency injection and control inversion
qt之.pro文件详解
Flink DataStream 类型系统 TypeInformation
SQL中HAVING和WHERE的区别
Alexnet model
利用 MATLAB 编程实现最速下降法求解无约束最优化问题
OPPO数据湖统一存储技术实践
22年了你还不知道文件包含漏洞?
Pnpm installation and use
Flink datastream type system typeinformation
编程哲学——自动加载、依赖注入与控制反转
[untitled]
L'externalisation a duré quatre ans.