-
Notifications
You must be signed in to change notification settings - Fork 0
/
where_exercises.sql
134 lines (93 loc) · 2.09 KB
/
where_exercises.sql
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
-- QUESTION 1
USE employees;
SELECT database ();
DESCRIBE employees;
SELECT * FROM employees.employees;
-- 2
SELECT first_name, last_name FROM employees.employees
WHERE first_name IN ('Irena', 'Vidya','Maya');
-- i got 709 rows returned
-- 3
SELECT first_name, last_name FROM employees
WHERE first_name = 'Irena' OR
first_name = 'Vidya'
OR
First_name = 'Maya';
# there is less rows I got 473
-- 4
SELECT first_name, last_name, Gender FROM employees
WHERE first_name = 'Irena' OR
first_name = 'Vidya'
OR
First_name = 'Maya'
AND gender = 'M';
-- 295 records retuned
SELECT first_name, last_name, gender FROM employees
WHERE Gender = ('M')
AND first_name = 'Irena' OR 'Vidya'
OR 'Maya';
# 144 rows
-- 5
SELECT count(*) last_name
FROM employees
WHERE last_name LIKE 'e%';
# 7330 employyees
-- 6
SELECT count(*) last_name
FROM employees
WHERE last_name LIKE 'E%'
OR LAST_name LIKE '%E';
-- retunred 30723 employees
SELECT count(*) last_name
FROM employees
WHERE last_name LIKE '%e';
-- retunred 24292 rows 31 employees
-- 7
SELECT last_name
FROM employees
WHERE last_name LIKE 'E%'
AND LAST_name LIKE '%E';
# I got 899 rows returned
-- SELECT count(*) last_name
-- FROM employees
-- WHERE last_name LIKE '%e';
-- 8
SELECT count(*) hire_date
FROM employees
WHERE hire_date BETWEEN '1990-01-01' AND '1999-12-31';
#there is 135214
-- 9
SELECT count(*) hire_date
FROM employees
WHERE hire_date LIKE '%-12-25';
SELECT hire_date
FROM employees
WHERE hire_date LIKE '%-12-25';
# 789 born on christmas
-- 10
SELECT hire_date, Birth_date
FROM employees
WHERE hire_date BETWEEN '1990-01-01' AND '1999-12-31'
AND Birth_date LIKE '%-12-25';
#287 retrun
-- SELECT hire_date
-- FROM employees
-- WHERE hire_date LIKE '%-12-25'
-- BETWEEN '1990-12-25' AND '1999-12-25';
-- 11
SELECT Count(*) last_name
FROM employees
WHERE last_name LIKE '%q%';
# 1873
-- 12
SELECT last_name
FROM employees
WHERE last_name LIKE '%q%' AND
last_name NOT LIKE '%qu%';
#547
-- #1873
-- SELECT Count(*) last_name
-- FROM employees
-- WHERE last_name LIKE '%qu%';
-- # 1326
-- #1873-1326=