From 2a468a404085c0e9d44cced44cc0144255c66240 Mon Sep 17 00:00:00 2001 From: Sibabalwe <102536140+Ngandana@users.noreply.github.com> Date: Wed, 20 Nov 2024 13:28:58 +0200 Subject: [PATCH] Update questions(my answers).sql --- SQL Deep Dive/Joins/Inner Join/questions.sql | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/SQL Deep Dive/Joins/Inner Join/questions.sql b/SQL Deep Dive/Joins/Inner Join/questions.sql index 61d86a4..60ec2ec 100644 --- a/SQL Deep Dive/Joins/Inner Join/questions.sql +++ b/SQL Deep Dive/Joins/Inner Join/questions.sql @@ -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 orderid, customerid, state +From orders +Inner JOIN customers using(customerid) +where state = 'NY' or state = 'OH' or state = 'OR' @@ -13,13 +17,19 @@ * Table: products * Question: Show me the inventory for each product */ - +SELECT p.prod_id, e.quan_in_stock +FROM products as p +inner join inventory as e On e.prod_id = p.prod_id /* * DB: Employees * Table: employees * Question: Show me for each employee which department they work in */ +SELECT e.emp_no, d.dept_no +FROM employees AS e +INNER JOIN dept_emp AS de ON e.emp_no = de.emp_no +INNER JOIN departments AS d ON de.dept_no = d.dept_no;