/* 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 description with rollup; /* Display total instructor payment by department */ select department, sum(gross_pay) from payment join course using (course_id) group by department with rollup; /* Display total instructor payment by course and department */ /* Notice output has 2 JavaScript records */ select department, c.description, format(sum(gross_pay),2) as "gross pay" from payment join course c using (course_id) group by department, c.description with rollup;