SQL Join Query Writing

Problem Write a SQL query involving a JOIN — for example, given an orders table and a customers table, list each customer's name alongside their total number of orders.

Schema

  • customers(customer_id, name, city)
  • orders(order_id, customer_id, order_value, created_at)

Output

  • One row per customer with their name and order count (or order total), including customers with zero orders when the prompt asks for all customers

Example

  • customers = {1: Asha, 2: Ravi}; orders = {(10, 1), (11, 1)}
  • Result: Asha → 2, Ravi → 0
asked …
LeaderboardSalaryAccount