blob: a8d2e0819292ca07c08f64a445665e476c055b7d [file] [log] [blame]
select warehouse.warehouse_country as c0, warehouse.warehouse_state_province as c1, warehouse.warehouse_city as c2, warehouse.warehouse_name as c3 from warehouse as warehouse, inventory_fact_1997 as inventory_fact_1997, time_by_day as time_by_day where inventory_fact_1997.warehouse_id = warehouse.warehouse_id and inventory_fact_1997.time_id = time_by_day.time_id and time_by_day.the_year = 1997 and time_by_day.quarter = 'Q2' group by warehouse.warehouse_country, warehouse.warehouse_state_province, warehouse.warehouse_city, warehouse.warehouse_name order by (sum(inventory_fact_1997.warehouse_sales) - sum(inventory_fact_1997.warehouse_cost)) DESC NULLS LAST, warehouse.warehouse_country ASC NULLS LAST, warehouse.warehouse_state_province ASC NULLS LAST, warehouse.warehouse_city ASC NULLS LAST, warehouse.warehouse_name ASC NULLS LAST;