Skip to content
Advertisement

SQL – Find total number of orders made for each customer

I have 2 tables customer and orders. Each customer can place multiple orders

  • customer has a column customer_num
  • orders has columns order_num, customer_num

I want the results to show like this:

enter image description here

Here is my current code which only returns all the distinct customer num

Advertisement

Answer

Try the below – using count() aggregation with group by

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement