当前位置:网站首页>SQL Server 2016 learning records - set query
SQL Server 2016 learning records - set query
2022-07-28 10:38:00 【Hard work Zhang Zhang】
Learning goals :
One 、 Related concepts of set query
Two 、 Several common operations of set query
Learning content :
One 、 Classification of set queries

Two 、 Several common operations of set query
1、 And operate
- form
< Query block >
union
< Query block >
- To participate in union The number of columns of each result of the operation must be the same
- The data type of the corresponding item must be the same
-- Check the elective course 1 Course No. and 2 The student number of course No
select sno from sc where cno=1
union
select sno from sc where cno=2;

2、 Alternating operation and differential operation
standard sql Set intersection and difference operations are not provided in , But it can be achieved indirectly by other methods
-- Check the elective course 1 The students of course No. 1 have gathered and selected 2 The intersection of the student set of course No
select sno from sc
where cno=1 and sno In
(select sno from sc
where cno=2);

-- Query computer science department students with age not older than 19 The difference set of a year old student
select * from student
where sdept='CS' and sage>19;

4、 Sort the results of set operations
- order by Clause can only be used to sort the final query results , Intermediate results cannot be sorted
- In any case ,order by Clause can only appear at the end
- When sorting the results of set operations ,order by The sorting attribute can be specified numerically in the clause
-- Query computer science department students with age not older than 19 The union of year-old students , The results are arranged in ascending order of student number
select * from student
where sdept='CS'
union
select * from student
where sage<=19
order by sno;

边栏推荐
- Uni app project directory, file function introduction and development specification
- Use of Ogg parameter filter [urgent]
- 20200229训练赛 L1 - 2 删除字符串中的子串 (20分)
- MySQL的SQL TRACE一例
- Problem summary file
- 第11届蓝桥杯本科组校赛(20200321)
- 2. Output one of the repeated numbers in the array
- Detailed explanation of super complete knowledge points of instruction system
- 阿里云镜像地址
- Bitwise and, or, XOR and other operation methods
猜你喜欢

Idea packages jar packages and runs jar package commands

SQL Server 2016 learning records - data update

最短路专题
![Implement a queue with two stacks [C language]](/img/8a/679575bb0a562eff7e4317e64b4790.png)
Implement a queue with two stacks [C language]

IDEA打包jar包及运行jar包命令

Inverse element & combinatorial number & fast power

6. Double pointer -- the sum of the two numbers of the incremental array is equal to the target number

Machine learning -- handwritten English alphabet 2 -- importing and processing data

数据库安全 --- 创建登录名 用户+配置权限【笔记】

机器人技术(RoboCup 2D)如何进行一场球赛
随机推荐
The 11th Blue Bridge Cup Undergraduate group competition (20200321)
5、Window端实现Mapreduce程序完成wordcount功能
5. Dynamic programming -- Fibonacci series
【微信小程序】项目实战—抽签应用
Database security - create login user + configure permissions [notes]
20200229训练赛 L2 - 2 树种统计 (25分)
Qt生成.exe文件 并 在无Qt环境下运行(Enigma Virtual Box进行绿色可执行软件封装)图文教程
20200229 training match L1 - 2 delete the substring in the string (20 points)
按位与、或、异或等运算方法
15. Judge whether the target value exists in the two-dimensional array
SDUT 2446 最终排名
Pl/sql server syntax explanation
Codeforces Round #614 (Div. 2) A. ConneR and the A.R.C. Markland-N
3. Print the linked list in reverse order with the array
11. Linked list inversion
It is said that the global semiconductor equipment giant may build a joint venture factory in Shanghai!
20200229 training race L2 - 2 tree species Statistics (25 points)
Shortest path topic
AP Autosar平台设计 1-2 导言、技术范围与方法
2. Output one of the repeated numbers in the array