子查询以及sql练习
无详细内容 无 --1列出emp表中各部门的部门号,最高工资,最低工资--先分组,后计算,SELECT e.deptno AS 部门号, MAX(e.sal) AS 最高工资, MIN(e.sal) AS 最低工资 FROM emp AS e GROUP BY e.deptno;--2 列出emp表中各部门job为'CLERK'的员工的最低工资,最
<无详细内容> <无>
--1列出emp表中各部门的部门号,最高工资,最低工资 --先分组,后计算, SELECT e.deptno AS 部门号, MAX(e.sal) AS 最高工资, MIN(e.sal) AS 最低工资 FROM emp AS e GROUP BY e.deptno; --2 列出emp表中各部门job为'CLERK'的员工的最低工资,最高工资 SELECT MIN(e.sal) AS 最低工资 , MAX(e.sal) FROM emp AS e WHERE e.job='CLERK' GROUP BY e.deptno; --3 对于emp中最低工资小于2000的部门,列出job为'CLERK'的员工的部门号,最低工资,最高工资 SELECT e.deptno AS 部门号, MIN(e.sal) AS 最低工资 , MAX(e.sal) AS 最高工资 FROM emp AS e WHERE e.job ='CLERK' AND (SELECT MIN(b.sal) FROM emp b) <2000 GROUP BY e.deptno; --4 根据部门号由高而低,工资有低而高列出每个员工的姓名,部门号,工资 SELECT e.ename AS 姓名 ,e.deptno AS 部门号, e.sal AS 工资 FROM emp AS e ORDER BY e.deptno DESC ,e.sal --5 列出'buddy'所在部门中每个员工的姓名与部门号 SELECT e.ename AS 姓名, e.deptno AS 部门号 FROM emp AS e WHERE e.deptno =(SELECT b.deptno FROM emp AS b WHERE b.ename='buddy'); --6 列出每个员工的姓名,工作,部门号,部门名 SELECT e.ename 姓名, e.job AS 工作 , e.deptno AS 部门号 FROM emp AS e , dept AS d WHERE e.deptno=d.deptno ; --7列出emp中工作为'CLERK'的员工的姓名,工作,部门号,部门名 SELECT e.ename AS 姓名, e.job AS 工作 ,d.dname AS 部门名 FROM emp AS e , dept AS d WHERE e.deptno =d.deptno AND e.job='CLERK'; --8对于emp中有管理者的员工,列出姓名,管理者姓名(管理者外键为mgr) SELECT a.deptno AS 部门号,a.ename AS 员工,b.ename AS 管理者 FROM emp AS a,emp AS b WHERE a.mgr IS NOT NULL AND a.mgr=b.ename; --9 对于dept表中,列出所有部门名,部门号,同时列出各部门工作为'CLERK'的员工名与工作 SELECT d.dname AS 部门名, d.deptno AS 部门号 ,e.ename AS 姓名 , e.job AS 工作 FROM dept AS d ,emp AS e WHERE e.deptno =d.deptno AND e.job='CLERK'; --10 对于工资高于本部门平均水平的员工,列出部门号,姓名,工资,按部门号排序 SELECT e.deptno AS 部门号,e.ename AS 姓名, e.sal AS 工资 FROM emp AS e WHERE e.sal >(SELECT AVG(el.sal) FROM emp AS el WHERE el.deptno=e.deptno) ORDER BY e.deptno; --11对于emp,列出各个部门中工资高于本部门平均工资的员工数和部门号,按部门号排序 SELECT COUNT(e.sal) AS 员工数,e.deptno AS 部门号 FROM emp AS e WHERE e.sal >(SELECT AVG(el.sal) FROM emp AS el WHERE e.deptno =el.deptno) GROUP BY e.deptno ORDER BY e.deptno; --12对于emp中工资高于本部门平均水平,人数多与1人的,列出部门号,人数,平均工资,按部门号排序 SELECT COUNT(a.empno) AS 员工数,a.deptno AS 部门号,AVG(sal) AS 平均工资 FROM emp AS a WHERE (SELECT COUNT(c.empno) FROM emp AS c WHERE c.deptno=a.deptno AND c.sal>(SELECT AVG(sal) FROM emp AS b WHERE c.deptno=b.deptno))>1 GROUP BY a.deptno ORDER BY a.deptno;

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

"Usage of Division Operation in OracleSQL" In OracleSQL, division operation is one of the common mathematical operations. During data query and processing, division operations can help us calculate the ratio between fields or derive the logical relationship between specific values. This article will introduce the usage of division operation in OracleSQL and provide specific code examples. 1. Two ways of division operations in OracleSQL In OracleSQL, division operations can be performed in two different ways.

Nowadays, many friends like to use Kingsoft Typing Assistant, but the typing speed seriously affects work efficiency, so I teach you to practice typing speed. So how to use Kingsoft Typing Assistant to practice typing? Today, the editor will give you a tutorial on how to practice typing numbers with Kingsoft Typing Assistant. The following is described, I hope it will be helpful to everyone. First, open the Kingsoft typing software, then click the (Getting Started) button with your mouse, then click the (Number Keys) button in a new window, then click the (Start from Scratch) button below to practice, or click the (Test Mode) button. , just enter numbers for practice. In addition, Kingsoft Typing Assistant has other functions that can help you practice typing better. 1. Select practice mode: On the software interface, you can see that there are different practice modes, such as "New

Oracle and DB2 are two commonly used relational database management systems, each of which has its own unique SQL syntax and characteristics. This article will compare and differ between the SQL syntax of Oracle and DB2, and provide specific code examples. Database connection In Oracle, use the following statement to connect to the database: CONNECTusername/password@database. In DB2, the statement to connect to the database is as follows: CONNECTTOdataba

Download the latest version of 12306 ticket booking app. It is a travel ticket purchasing software that everyone is very satisfied with. It is very convenient to go wherever you want. There are many ticket sources provided in the software. You only need to pass real-name authentication to purchase tickets online. All users You can easily buy travel tickets and air tickets and enjoy different discounts. You can also start booking reservations in advance to grab tickets. You can book hotels or special car transfers. With it, you can go where you want to go and buy tickets with one click. Traveling is simpler and more convenient, making everyone's travel experience more comfortable. Now the editor details it online Provides 12306 users with a way to view historical ticket purchase records. 1. Open Railway 12306, click My in the lower right corner, and click My Order 2. Click Paid on the order page. 3. On the paid page

How to check my academic qualifications on Xuexin.com? You can check your academic qualifications on Xuexin.com, but many users don’t know how to check their academic qualifications on Xuexin.com. Next, the editor brings you a graphic tutorial on how to check your academic qualifications on Xuexin.com. Interested users come and take a look! Xuexin.com usage tutorial: How to check your academic qualifications on Xuexin.com 1. Xuexin.com entrance: https://www.chsi.com.cn/ 2. Website query: Step 1: Click on the Xuexin.com address above to enter the homepage Click [Education Query]; Step 2: On the latest webpage, click [Query] as shown by the arrow in the figure below; Step 3: Then click [Login Academic Credit File] on the new page; Step 4: On the login page Enter the information and click [Login];

Database technology competition: What are the differences between Oracle and SQL? In the database field, Oracle and SQL Server are two highly respected relational database management systems. Although they both belong to the category of relational databases, there are many differences between them. In this article, we will delve into the differences between Oracle and SQL Server, as well as their features and advantages in practical applications. First of all, there are differences in syntax between Oracle and SQL Server.

CheatEngine is a game editor that can edit and modify the game's memory. However, its default language is non-Chinese, which is inconvenient for many friends. So how to set Chinese in CheatEngine? Today, the editor will give you a detailed introduction to how to set up Chinese in CheatEngine. I hope it can help you. Setting method one: 1. Double-click to open the software and click "edit" in the upper left corner. 2. Then click “settings” in the option list below. 3. In the opened window interface, click "languages" in the left column
