-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions_exercises.sql
More file actions
20 lines (10 loc) · 1009 Bytes
/
functions_exercises.sql
File metadata and controls
20 lines (10 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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 desc, last_name desc;
select * from employees where first_name in ('Irena', 'Vidya', 'Maya') ORDER BY last_name desc, first_name desc;
SELECT CONCAT(first_name, ' ', last_name) FROM employees WHERE first_name LIKE 'e%' AND last_name LIKE '%e';
SELECT * FROM employees WHERE DAY(birth_date) = 25 AND MONTH(birth_date) = 12;
SELECT * FROM employees WHERE DAY(birth_date) = 25 AND MONTH(birth_date) = 12 AND hire_date LIKE '199%';
SELECT * FROM employees WHERE DAY(birth_date) = 25 AND MONTH(birth_date) = 12 AND hire_date LIKE '199%' ORDER BY birth_date, hire_date DESC;
# DATEDIFF returns values in days, NOW() returns values in seconds
SELECT DATEDIFF(NOW(), hire_date), CONCAT(first_name, ' ', last_name) FROM employees WHERE DAY(birth_date) = 25 AND MONTH(birth_date) = 12 AND hire_date LIKE '199%';