-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUnions
More file actions
55 lines (44 loc) · 1.52 KB
/
Copy pathUnions
File metadata and controls
55 lines (44 loc) · 1.52 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
xxx==============================================================================================================xxx
[Notes - For viewing two table with specific row, here it's EmployeeID, Age, Gender]
SELECT FirstName
FROM EmployeeDemographics
UNION
SELECT JobTitle
FROM EmployeeSalary
;
xxx==============================================================================================================xxx
SELECT FirstName
FROM EmployeeDemographics
UNION ALL
SELECT JobTitle
FROM EmployeeSalary
;
xxx==============================================================================================================xxx
SELECT FirstName, LastName, 'Old' as Label
FROM EmployeeDemographics
WHERE AGE > 30
;
xxx==============================================================================================================xxx
SELECT EmployeeID, 'Old' as Label
FROM EmployeeDemographics
WHERE AGE > 30
UNION
SELECT EmployeeID, 'Highly Paid' as Label
FROM EmployeeSalary
WHERE Salary > 40000
;
xxx==============================================================================================================xxx
SELECT EmployeeID, 'Old Man' as Label
FROM EmployeeDemographics
WHERE AGE > 30 AND Gender = 'Male'
UNION
SELECT EmployeeID, 'Old Woman' as Label
FROM EmployeeDemographics
WHERE AGE > 30 AND Gender = 'FeMale'
UNION
SELECT EmployeeID, 'Highly Paid' as Label
FROM EmployeeSalary
WHERE Salary > 40000
ORDER BY EmployeeID
;
xxx==============================================================================================================xxx