当前位置:网站首页>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
边栏推荐
- LeetCode153-寻找旋转排序数组中的最小值-数组-二分查找
- 【NLP】HMM隐马尔可夫+维特比分词
- eolink 如何助力遠程辦公
- Provided by Chengdu control panel design_ It's detailed_ Introduction to the definition, compilation and quotation of single chip microcomputer program header file
- ASEMI整流模块MDQ100-16在智能开关电源中的作用
- 【工厂模式详解】工厂方法模式
- Async keyword
- Pnpm installation and use
- select 同时接收普通数据 和 带外数据
- 拼接hql时,新增字段没有出现在构造方法中
猜你喜欢
Arduino for esp8266串口功能简介
[untitled]
Leetcode167 - sum of two numbers II - double pointer - bisection - array - Search
Leetcode162 - find peak - dichotomy - array
Model location setting in GIS data processing -cesium
成都控制板设计提供_算是详细了_单片机程序头文件的定义、编写及引用介绍
A good tool: aardio
LeetCode165-比较版本号-双指针-字符串
[servlet] detailed explanation of servlet (use + principle)
OC to swift conditional compilation, marking, macro, log, version detection, expiration prompt
随机推荐
GIS数据处理-cesium中模型位置设置
详解TCP的三次握手
Leetcode165 compare version number double pointer string
Outsourcing for four years, abandoned
每日一题-LeetCode396-旋转函数-递推
[jz46 translate numbers into strings]
Pnpm installation and use
epoll 的 ET,LT工作模式———实例程序
[detailed explanation of factory mode] factory method mode
Unity_ Code mode add binding button click event
What is the effect of Zhongfu Jinshi wealth class 29800? Walk with professional investors to make investment easier
Swift - literal, literal protocol, conversion between basic data types and dictionary / array
The art of automation
脏读、不可重复读和幻读介绍
科技的成就(二十一)
The difference between having and where in SQL
【Proteus仿真】自动量程(范围<10V)切换数字电压表
we引用My97DatePicker 实现时间插件使用
[stc8g2k64s4] introduction of comparator and sample program of comparator power down detection
Sqlserver transaction and lock problem