# 3.9.1 Assignment

course: Academy — 65-GENAI-for-Engineers
module: Academy/65-GENAI-for-Engineers
type: pdf
source_url: https://personal-learn.armco.dev/files/Academy/65-GENAI-for-Engineers/assignments/3.9.1_Assignment__RIGHT_JOIN_and_FULL_JOIN_Explained/3.9.1_Assignment.pdf
pages: 3

---
[page 1]
Assignment Questions: RIGHT JOIN & FULL JOIN 
 1. Explain with an example: When would you prefer RIGHT JOIN over LEFT 
 JOIN? 
 Instructions: 
 ●  Describe a real-world use case (e.g., students and marks, products and sales). 
 ●  Write a short SQL query using RIGHT JOIN. 
 ●  Explain why RIGHT JOIN is better suited in your example. 
 2. Write a query using RIGHT JOIN that lists all sales, even if some 
 products are missing from the product list. 
 Tables: 
 ●  sales(sale_id, product_id, amount) 
 ●  products(product_id, product_name) 
 Expected Output: 
 ●  product_name, amount 
 ●  If the product is missing, show NULL in product_name. 
 3. Create a scenario where FULL JOIN is the best choice. Explain your 
 answer and show the query. 
 Instructions: 
 ●  Think of a real case (e.g., comparing employees with time logs, student attendance vs. 
 assignment submissions). 
 ●  Describe why FULL JOIN is important here. 
 ●  Write a query using FULL JOIN.

[page 2]
4. Given two tables with mismatched records, use FULL JOIN to list all 
 entries and highlight unmatched rows using a  CASE  statement. 
 Tables: 
 ●  employees(emp_id, name) 
 ●  timesheet(emp_id, hours_logged) 
 Task: 
 ●  Write a query that shows: 
 ○  emp_id, name, hours_logged, status 
 ○  status = 'Only in employees' / 'Only in timesheet' / 'Matched' 
 5. Consider the following data and write the FULL JOIN output manually. 
 Table A: customers 
 customer_id  name 
 1  Alice 
 2  Bob 
 3  Carol 
 Table B: orders 
 customer_id  order_id 
 1  101 
 2  102 
 4  103 
 Task: 
 ●  Write the result of  FULL JOIN  between customers and  orders on customer_id. 
 ●  Include all columns and use  NULL  where needed.

[page 3]
6. What is the difference between RIGHT JOIN and FULL JOIN? Write two 
 queries and explain their outputs using the same tables. 
 7. Modify a FULL JOIN query to only show unmatched rows (i.e., rows 
 where one side is NULL). 
 Hint:  Use  WHERE  clause to filter out matched rows. 
 8. Create two sample tables with at least 5 rows each, where some keys 
 match and some don’t. Perform: 
 ●  INNER JOIN 
 ●  RIGHT JOIN 
 ●  FULL JOIN 
 Compare the output and explain what differences you see.