-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSubquery
More file actions
30 lines (25 loc) · 791 Bytes
/
Subquery
File metadata and controls
30 lines (25 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
xxx==============================================================================================================xxx
SELECT *
FROM EmployeeDemographics
WHERE EmployeeID IN
(SELECT EmployeeID
FROM EmployeeSalary
WHERE JobTitle = 'Accountant')
;
xxx==============================================================================================================xxx
SELECT JobTitle,
(SELECT AVG(Salary)
FROM EmployeeSalary)
FROM EmployeeSalary
;
xxx==============================================================================================================xxx
SELECT AVG(avg_age), AVG(min_age), AVG(max_age)
FROM
(SELECT Gender,
AVG(Age) AS avg_age,
MIN(Age) AS min_age,
MAX(Age) AS max_age,
COUNT(Age) AS count_age
FROM EmployeeDemographics
GROUP BY Gender) AS age_table
;