Skip to content
Open
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: 9 additions & 5 deletions SQL Deep Dive/Joins/Inner Join/questions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
* Question: Get all orders from customers who live in Ohio (OH), New York (NY) or Oregon (OR) state
* ordered by orderid
*/
select c.firstname, c.lastname, o.orderid from orders AS o
INNER JOIN customers AS c ON o.customerid = c.customerid
where c.state IN ('OH','NY','OR')
ORDER BY o.orderid;



Expand All @@ -13,14 +17,14 @@
* Table: products
* Question: Show me the inventory for each product
*/

select p.prod_id, i.quan_in_stock from products as p
INNER JOIN inventory as i on p.prod_id = i.prod_id;

/*
* DB: Employees
* Table: employees
* Question: Show me for each employee which department they work in
*/




select e.first_name, dp_dept_name from employees as e
INNER JOIN dept_emp as d on de.emp_no = e.empno
INNER JOIN departments as dp on dp.dept_no = de.emp_no;