# 4.2 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/4.2_Assignment__Solving_Real-life_Query_Challenges/4.2_Assignment.pdf pages: 1 --- [page 1] 4.2 Assignment Questions Short Answer / Conceptual Questions 1. Why is it important to understand the business context before writing SQL queries? 2. Describe a situation where using HAVING instead of WHERE is necessary. 3. Explain the difference between filtering with WHERE and filtering with CASE . Hands-On / Practical Tasks 4. Based on a sample e-commerce database, write SQL queries to: a. Find the top 3 best-selling products in the last month (use GROUP BY , SUM() , ORDER BY , LIMIT ) b. Identify customers who made purchases in at least 3 different months (use COUNT(DISTINCT MONTH(date)) ) c. Compare total revenue between first-time and repeat customers using CASE and GROUP BY 5. Given a table StockLog(ProductID, Date, InStock) , write a query to list all products that were out of stock ( InStock = 0 ) for more than 5 days in the last 30 days. 6. Design a real-life query challenge based on your domain (e.g., education, retail, finance), define the problem clearly, and write the SQL logic (or pseudo-code) that would solve it step-by-step.