-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgroup_by_exercise.sql
49 lines (31 loc) · 987 Bytes
/
group_by_exercise.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
USE employees;
SELECT DISTINCT title, from_date
FROM titles;
SELECT title
FROM titles
GROUP BY title;
SELECT DISTINCT first_name, last_name
FROM employees
WHERE last_name LIKE 'E%' AND last_name LIKE '%E';
SELECT DISTINCT last_name
FROM employees
WHERE last_name LIKE 'q%' AND NOT last_name LIKE 'qu%';
SELECT concat(first_name, ' ', last_name)
FROM employees;
SELECT now(), curdate(), curtime();
SELECT CONCAT(
'Teaching People to Code for ',
UNIX_TIMESTAMP() - UNIX_TIMESTAMP('2016-12-08'),
' seconds'
);
SELECT( UNIX_TIMESTAMP() - UNIX_TIMESTAMP(hire_date)) / (60 * 60 * 24 * 3365)
FROM employees;
SELECT count(*) from employees where gender = 'M';
select count(*) from employees where gender = 'F';
select count(*) AS 'Count of Genders', gender AS 'Gen' from employees
GROUP BY gender;
SELECT * from employees
where first_name = 'Yonghong' and last_name = 'Codenie';
DESCRIBE salaries;
select * from salaries;
select AVG(salary) from salaries group by emp_no;