1 2 3 4 5 6 7 8
|
select distinct c.name as "name",
(select s.total from sales_order s where s.customer_id=c.customer_id and to_char(s.order_date, 'Q')=1) as "1st",
(select s.total from sales_order s where s.customer_id=c.customer_id and to_char(s.order_date, 'Q')=2) as "2nd",
(select s.total from sales_order s where s.customer_id=c.customer_id and to_char(s.order_date, 'Q')=3) as "3rd",
(select s.total from sales_order s where s.customer_id=c.customer_id and to_char(s.order_date, 'Q')=4) as "4th"
from customer c, sales_order s
where c.customer_id=s.customer_id; |