-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlimit_exercises.sql
More file actions
34 lines (29 loc) · 909 Bytes
/
limit_exercises.sql
File metadata and controls
34 lines (29 loc) · 909 Bytes
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
USE employees;
-- List the first 10 distinct last name sorted in descending order
SELECT DISTINCT last_name
FROM employees
ORDER BY last_name DESC
LIMIT 10;
-- Find your query for employees born on Christmas
-- and hired in the 90s from order_by_exercises.sql.
-- Update it to find just the first 5 employees
SELECT DISTINCT first_name, last_name, birth_date, hire_date
FROM employees
WHERE birth_date
LIKE '%-12-25'
AND hire_date
LIKE '199%'
ORDER BY birth_date, hire_date DESC
Limit 5;
-- Update the query to find the tenth page of results.
SELECT DISTINCT first_name, last_name, birth_date, hire_date
FROM employees
WHERE birth_date
LIKE '%-12-25'
AND hire_date
LIKE '199%'
ORDER BY birth_date, hire_date DESC
LIMIT 5 OFFSET 45;
-- What is the relationship between OFFSET (number of results to skip),
-- LIMIT (number of results per page), and the page number?
-- OFFSET = PAGE(LIMIT) - LIMIT