                                                                                                                     QUERY PLAN                                                                                                                      
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=895753.37..895753.62 rows=100 width=210)
   ->  Sort  (cost=895753.37..895755.87 rows=1001 width=210)
         Sort Key: ((GROUPING(item.i_category) + GROUPING(item.i_class))) DESC, (CASE WHEN (((GROUPING(item.i_category) + GROUPING(item.i_class))) = 0) THEN item.i_category ELSE NULL::bpchar END), (rank() OVER (?))
         ->  WindowAgg  (cost=895680.08..895715.11 rows=1001 width=210)
               ->  Sort  (cost=895680.08..895682.58 rows=1001 width=178)
                     Sort Key: ((GROUPING(item.i_category) + GROUPING(item.i_class))), (CASE WHEN (GROUPING(item.i_class) = 0) THEN item.i_category ELSE NULL::bpchar END), ((sum(store_sales.ss_net_profit) / sum(store_sales.ss_ext_sales_price)))
                     ->  MixedAggregate  (cost=11589.90..895630.19 rows=1001 width=178)
                           Hash Key: item.i_category, item.i_class
                           Hash Key: item.i_category
                           Group Key: ()
                           ->  Hash Join  (cost=11589.90..892813.46 rows=124187 width=114)
                                 Hash Cond: (store_sales.ss_item_sk = item.i_item_sk)
                                 ->  Hash Join  (cost=2330.90..883228.46 rows=124187 width=16)
                                       Hash Cond: (store_sales.ss_store_sk = store.s_store_sk)
                                       ->  Hash Join  (cost=2322.65..882847.36 rows=136613 width=20)
                                             Hash Cond: (store_sales.ss_sold_date_sk = d1.d_date_sk)
                                             ->  Seq Scan on store_sales  (cost=0.00..804917.92 rows=28800992 width=24)
                                             ->  Hash  (cost=2318.11..2318.11 rows=363 width=4)
                                                   ->  Seq Scan on date_dim d1  (cost=0.00..2318.11 rows=363 width=4)
                                                         Filter: (d_year = 2001)
                                       ->  Hash  (cost=7.04..7.04 rows=97 width=4)
                                             ->  Seq Scan on store  (cost=0.00..7.04 rows=97 width=4)
                                                   Filter: (s_state = ANY ('{TN,TN,TN,TN,TN,TN,TN,TN}'::bpchar[]))
                                 ->  Hash  (cost=7984.00..7984.00 rows=102000 width=106)
                                       ->  Seq Scan on item  (cost=0.00..7984.00 rows=102000 width=106)
(25 rows)

