-
Notifications
You must be signed in to change notification settings - Fork 0
/
order_by_exercises.sql
83 lines (60 loc) · 1.91 KB
/
order_by_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
/*Code from where clause exercises */
use employees;
select * from employees
where first_name in ('Irena', 'Vidya', 'Maya');
select * from employees
where first_name like 'E%';
select count(*) from employees
where hire_date between '1990-01-01' and '1999-12-31';
select * from employees
where birth_date like '%-12-25';
select * from employees
where last_name like '%q%';
select * from employees
where first_name = 'Irena' or first_name = 'Vidya' or first_name = 'Maya';
select * from employees
where gender = 'M'
AND (first_name = 'Irena' or first_name = 'Vidya' or first_name = 'Maya');
select * from employees
where last_name like '%E' or last_name like 'E%';
select * from employees
where last_name like '%E' and last_name like 'E%';
select * from employees
where birth_date like '%-12-25'
and hire_date between '1990-01-01' and '1999-12-31';
select * from employees
where last_name like '%q%'
and last_name not like '%qu%'
/* Order By Exercise Answers */
use employees;
select * from employees
where first_name in ('Irena', 'Vidya', 'Maya')
order by first_name;
select * from employees
where first_name in ('Irena', 'Vidya', 'Maya')
order by first_name, last_name;
select * from employees
where first_name in ('Irena', 'Vidya', 'Maya')
order by last_name, first_name;
select * from employees
where first_name like 'E%'
order by emp_no;
select * from employees
where last_name like '%E' or last_name like 'E%'
order by emp_no;
select * from employees
where last_name like '%E' and last_name like 'E%'
order by emp_no;
select * from employees
where first_name like 'E%'
order by emp_no DESC;
select * from employees
where last_name like '%E' or last_name like 'E%'
order by emp_no DESC;
select * from employees
where last_name like '%E' and last_name like 'E%'
order by emp_no DESC;
select * from employees
where birth_date like '%-12-25'
and hire_date between '1990-01-01' and '1999-12-31'
order by birth_date asc, hire_date desc