当前位置:网站首页>I learned database at station B (V): DQL exercise
I learned database at station B (V): DQL exercise
2022-06-30 00:59:00 【Who can take me to learn penetration】
Last one : I am here b Station learning database ( Four ):DQL
DQL Basic query operation exercise
Exercise one :
Data preparation :

1、 Query all student information in the table
select *
from student;
2、 Look up the names of all the students and their English scores
select name,english
from student;
3、 Filter out duplicate data
selcet distct *
from student;
4、 Count the total score of each student
select name,(chinese + english + math) as total_score
from student;
5、 Add... To the total score of all students 10 Points of specialty points of
select name,(chinese + english + math +10) as total_score
from student;
6、 Use aliases to indicate student scores
select name,chinese' Chinese achievement ',english' English scores ',math' Math scores '
from student;
7、 Query English score greater than 90 Classmate
select *
from student
where english > 90;
8、 Total query score greater than 200 All my classmates
select *
from student
where (chinese + english + math)> 200;
9、 Query English scores in 80-90 Between the students
select *
from student
where english between 80 and 90;
perhaps
select *
from student
where english >= 80 and <= 90;
10、 Query English score is not in 80-90 Between the students
The first one is
select *
from student
where not (english between 80 and 90);
The second kind
select *
from student
where english not between 80 and 90;
The third kind of
select *
from student
where not (english >= 80 and <=90);
A fourth
select *
from student
where english < 80 || english > 90;
11、 Query math score is 89,90,91 Classmate
select *
from student
where math in(89,90,91);
12、 Check the English scores of all students surnamed Li
select name,english
from student
where name like ' Li %';
13、 Query math score 80 And Chinese is divided into 80 Classmate
select *
from student
where math = 80 and chinese = 80;
14、 Query English 80 Or total score 200 Classmate
select *
from student
where english = 80 and (chinese + english + math) = 200;
15、 Output the math scores in descending order
select *
from stdent
order by math desc;
16、 After sorting the total score, output , And then output it from high to low
select *
from stdent
order by (chinese + english + math) desc;
17、 Sort the students' grades by their surname Li
select *
from student
where name like ' Li %'
order by (chinese + english + math) desc;
18、 How many boys and girls are there , And output the number of people in descending order , The number of people queried is greater than 4 Number of men and women
select gender,count(*) as toatl-cnt
from student
group by gender
having total_cnt > 4
order by total_cnt desc
Exercise 2
Data preparation :

1、 By employee The number is not in ascending order 10 Employee information of department No
select *
from emp
where deptno != 10
order by empno desc;
2、 The second letter of the query name is not ’A’ And the salary is greater than 1000 Employee information for , In descending order of annual salary
select *
from emp
where ename not like '_A%' and sal >1000
order by (12 * sal + innull(comm,0))
#ifnull(comm,0) If comm The value of is null, As if 0, Not for null, Then it is still the original value
3、 Average salary for each department
The first one is
select deptno,avg(sal)
from emp
group by deptno;
The second kind
select deptno,avg(sal) as avg_sal
from emp
group by deptno
order by avg_sal desc;
4、 Ask for the highest salary in each department
select deptno,max(sal) max_avg
from emp
group by deptno;
5、 Ask for the highest salary for each position in each department
select deptno,job,max(sal)
from emp
group by deptno,job
order by deptno;
6、 The average salary is greater than 2000 Department number of
select deptno,avg(sal) avg_sal
from emp
group by deptno
having avg_sal >2000;
7、 The average salary of the Department will be greater than 1500 The department number of the , Rank by department average salary in descending order
select deptno,avg(sal) avg_sal
from emp
group by deptno
having avg_sal >1500
order by avg_sal desc;
8、 Choose the name of the employee in the company who has the bonus , Wages
select *
from emp
where comm is not null;
9、 Find out the difference between the maximum wage and the minimum wage
select max(sal) - min(sal) ' Pay gap '
from emp;
边栏推荐
- ResizeKit2.NET大小和分辨率独立
- C语言课设心得之“推箱子”课设作品开源分享
- 传统微服务框架如何无缝过渡到服务网格 ASM
- 在线文本数字识别列表求和工具
- VIM编辑器常用指令
- Using tsne to visualize the similarity of different sentences
- How to switch to root in xshell
- 网易云音乐内测音乐社交 App“MUS”,通过音乐匹配同频朋友
- In 2022, the latest and most detailed idea associated database method and visual operation of database in idea (including graphic process)
- 解决choice金融终端Excel/Wps插件修复visual basic异常
猜你喜欢

How did the data center change from "Britney Spears" to "Mrs. bull"?

Analysis of IM instant messaging development technology on modern web

Simple pages

UDP servers and clients in go

如何做好测试用例设计

CSV文件格式——方便好用个头最小的数据传递方式

Stimulsoft Reports报告工具,Stimulsoft创建和构建报告

练习副“产品”:自制七彩提示字符串展示工具(for循环、if条件判断)

如何在IDEA中自定義模板、快速生成完整的代碼?
![[mrctf2020]ezpop-1 | PHP serialization](/img/f8/6164b4123e0d1f3b90980ebb7b4097.png)
[mrctf2020]ezpop-1 | PHP serialization
随机推荐
HC32M0+ GPIO
C语言课设心得之“推箱子”课设作品开源分享
Nested call and chained access of functions in handwritten C language
玉米地里的小鸟
UDP servers and clients in go
php微信商家转账到零钱 发起商家转账API
快手伸手“供给侧”,找到直播电商的“源头活水”?
[spark] basic Scala operations (continuous update)
Analysis of IM instant messaging development technology on modern web
Crmeb SMS for program configuration of knowledge payment system
Antd - tree structure: default deployment node attribute failure - Basic promotion
SFDP super form development platform v6.0.4 was officially released
Taguchi experimental method
IDEA中的常用设置
练习副“产品”:自制七彩提示字符串展示工具(for循环、if条件判断)
In depth analysis of a large number of clos on the server_ The root of wait
A Yu's Rainbow Bridge
Yunna | fixed assets system management, NC system management where are the fixed assets
简单的页面
【深度学习编译】算子编译 IR 转换