当前位置:网站首页>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
边栏推荐
- Arduino for esp8266串口功能简介
- 【JZ46 把数字翻译成字符串】
- Achievements in science and Technology (21)
- Set up an AI team in the game world and start the super parametric multi-agent "chaos fight"
- OC 转 Swift 条件编译、标记、宏、 Log、 版本检测、过期提示
- ASEMI三相整流桥和单相整流桥的详细对比
- Swift protocol Association object resource name management multithreading GCD delay once
- Go basic reflection
- 抑郁症治疗的进展
- raised exception class EAccexxViolation with ‘Access violation at address 45EFD5 in module 出错
猜你喜欢
电容
3、 Gradient descent solution θ
每日一题-LeetCode396-旋转函数-递推
LeetCode153-寻找旋转排序数组中的最小值-数组-二分查找
Swift: entry of program, swift calls OC@_ silgen_ Name, OC calls swift, dynamic, string, substring
SVN详细使用教程
MDS55-16-ASEMI整流模块MDS55-16
Leetcode153 - find the minimum value in the rotation sort array - array - binary search
Leetcode167 - sum of two numbers II - double pointer - bisection - array - Search
8.3 语言模型与数据集
随机推荐
[servlet] detailed explanation of servlet (use + principle)
eolink 如何助力远程办公
Model location setting in GIS data processing -cesium
你还不知道责任链模式的使用场景吗?
When splicing HQL, the new field does not appear in the construction method
1 - first knowledge of go language
Vscode Chinese plug-in doesn't work. Problem solving
Pnpm installation and use
ASEMI三相整流桥和单相整流桥的详细对比
Practice of unified storage technology of oppo data Lake
PCIe X1 插槽的主要用途是什么?
外包幹了四年,廢了...
epoll 的 ET,LT工作模式———实例程序
Swift Protocol 关联对象 资源名称管理 多线程GCD 延迟 once
填充每个节点的下一个右侧节点指针 II [经典层次遍历 | 视为链表 ]
Sword finger offer II 019 Delete at most one character to get palindrome (simple)
Role of asemi rectifier module mdq100-16 in intelligent switching power supply
A good tool: aardio
Borui data and F5 jointly build the full data chain DNA of financial technology from code to user
Unity_代码方式添加绑定按钮点击事件