create view v2 as select count(order_id) from orders; create view v3 as select distinct count(customer_id) from customers; create view v4 as select avg(rating) from ...
select customer_id,count(order_id) as total_orders, sum(amount) as total_spend from orders group by customer_id having count(order_id) >=3 select name, price, case ...