SELECT e.name, COUNT(o.id) AS orders,
       SUM(o.total) AS revenue
FROM employees e
LEFT JOIN orders o
  ON o.employee_id = e.id
WHERE o.placed_at >= '2025-01-01'
GROUP BY e.name
HAVING revenue > 5000
ORDER BY revenue DESC;
employeesid · PKnamedept_id · FKordersid · PKemployee_id · FKtotal
SQLearner

Choose the path that gets you job-ready faster.

1
2
3

Elite adds: AI SQL Mentor · Advanced projects · Full 22-level path

Elite Annual

$184.84 due today

That's only $15.40/month

Renews annually — cancel anytime

Try it for 14 days, risk-free.

Secure checkout by Lemon Squeezy Visa · Mastercard · Amex

Your progress

Level 12 of 22

55% complete

Your learning path

  1. 1 Foundations
  2. 2 Joins & Relationships
  3. 3 Aggregations
  4. 4
    4 Advanced Queries
  5. 5
    5 Window Functions
  6. 6
    6 Data Analysis