EXPLAIN select sum(l_extendedprice) / 7.0 as avg_yearly from lineitem, part where p_partkey = l_partkey and p_brand = 'Brand#24' and p_container = 'WRAP JAR' and l_quantity < ( select 0.2 * avg(l_quantity) from lineitem where l_partkey = p_partkey ); plan --------------------------------------------------- map groupby join hash join map groupby hash groupjoin tablescan tablescan part lineitem groupbyscan tablescan lineitem (13 rows)