how many orders are there
select count ( * ) from invoices
find the ten customers with the most total orders
select * from customers as t1 join invoices as t2 on t2.customer_id = t1.id group by t1.id order by count ( * ) desc limit 10
how many orders do each of them have?
select count ( * ) from customers as t1 join invoices as t2 on t2.customer_id = t1.id group by t1.id order by count ( * ) desc limit 10
how many customers are there
select count ( * ) from customers
how many customers have 7 or more orders
select count ( * ) from ( select * from customers as t1 join invoices as t2 on t2.customer_id = t1.id group by t1.id having count ( * ) > = 7 )