Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update questions.sql #84

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions SQL Deep Dive/Distinct/questions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@
* Question: What unique titles do we have?
*/

SELECT * FROM titles;
SELECT DISTINCT(title)
FROM titles


/*
* DB: Employees
* Table: employees
* Question: How many unique birth dates are there?
*/

SELECT * FROM employees;
SELECT DISTINCT(COUNT(birth_date))
FROM Employees;

/*
* DB: World
* Table: country
* Question: Can I get a list of distinct life expectancy ages
* Make sure there are no nulls
*/

SELECT * FROM country;

SELECT DISTINCT(lifeexpectancy)
FROM country
WHERE lifeexpectancy is not null
order BY lifeexpectancy ASC;
10 changes: 10 additions & 0 deletions SQL Deep Dive/Order By/questions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,27 @@
* Table: employees
* Question: Sort employees by first name ascending and last name descending
*/
SELECT first_name, last_name
FROM employees
ORDER BY first_name ASC, last_name desc;


/*
* DB: Employees
* Table: employees
* Question: Sort employees by age
*/
SELECT first_name, last_name, EXTRACT(YEAR FROM AGE(birth_date)) AS Age
FROM employees
ORDER BY age;


/*
* DB: Employees
* Table: employees
* Question: Sort employees who's name starts with a "k" by hire_date
*/
SELECT *
FROM employees
WHERE first_name ILIKE 'k%'
ORDER BY hire_date;