select time_by_day.the_year as c0, time_by_day.quarter as c1, store.store_state as c2, employee.management_role as c3, sum(salary.salary_paid) as m0, count(salary.employee_id) as m1, count(distinct salary.employee_id) as m2 from time_by_day as time_by_day, salary as salary, store as store, employee as employee where salary.pay_date = time_by_day.the_date and time_by_day.the_year = 1997 and salary.employee_id = employee.employee_id and employee.store_id = store.store_id and store.store_state in ('CA', 'OR', 'WA') group by time_by_day.the_year, time_by_day.quarter, store.store_state, employee.management_role; |