/* SCD - Slowly Changing Dimension - Type 2 - Course dimension */ /* Department for JavaScript changed - New row is added when changed */ select * from course; /* Display total instructor payment by course description */ select c.description, sum(gross_pay) from payment join course c using (course_id) group by rollup(description); /* Display total instructor payment by department */ select department, sum(gross_pay) from payment join course using (course_id) group by rollup(department); /* Display total instructor payment by department and course description */ /* Notice output has 2 JavaScript records */ select department, c.description, to_char(sum(gross_pay),'999,999.00') as "gross pay" from payment join course c using (course_id) group by rollup(department, c.description);