select time_by_day.the_year as c0, time_by_day.quarter as c1, store.store_country as c2, store.store_state as c3 from time_by_day as time_by_day, sales_fact_1997 as sales_fact_1997, store as store where sales_fact_1997.time_id = time_by_day.time_id and sales_fact_1997.store_id = store.store_id and (time_by_day.quarter in ('Q1', 'Q2') and time_by_day.the_year = 1997) and (store.store_state in ('CA', 'WA')) group by time_by_day.the_year, time_by_day.quarter, store.store_country, store.store_state order by time_by_day.the_year ASC NULLS LAST, time_by_day.quarter ASC NULLS LAST, store.store_country ASC NULLS LAST, store.store_state ASC NULLS LAST; |