select t2rp1 as g0, t3rp1 as g1, t4rp1 as g2, cast(avg(cc.creditCard_lastChargeAmount) as int) as p0, min(cc.creditCard_lastChargeTimestamp) as p1, count(distinct(cc.creditCard_holder)) as p2 from CategoryView ca left outer join ProductView p on ca.category_name = p.product_categoryName left outer join OrderItemView oi on p.product_id = oi.orderItem_productId left outer join OrderView o on oi.orderItem_orderId = o.order_id left outer join CreditCardView cc on o.order_creditCardNumber = cc.creditCard_number left outer join ( select sum(taxRecord_bracket) as t1rp1, ca.category_name as t1pk from CategoryView ca left outer join ProductView p on ca.category_name = p.product_categoryName left outer join OrderItemView oi on p.product_id = oi.orderItem_productId left outer join OrderView o on oi.orderItem_orderId = o.order_id left outer join CustomerView c on o.order_customerId = c.customer_id left outer join AddressView a on c.customer_id = a.address_customerId left outer join TaxRecordView t on a.address_id = t.taxRecord_addressId group by ca.category_name ) t1 on ca.category_name = t1pk left outer join ( select max(p.product_likes) as t2rp1, ca.category_name as t2pk from CategoryView ca left outer join ProductView p on ca.category_name = p.product_categoryName group by ca.category_name ) t2 on ca.category_name = t2pk left outer join ( select sum(oi.orderItem_productGroup) as t3rp1, ca.category_name as t3pk from CategoryView ca left outer join ProductView p on ca.category_name = p.product_categoryName left outer join OrderItemView oi on p.product_id = oi.orderItem_productId where oi.orderItem_weight > 15.0 group by ca.category_name ) t3 on ca.category_name = t3pk left outer join ( select max(cc.creditCard_zip) as t4rp1, ca.category_name as t4pk from CategoryView ca left outer join ProductView p on ca.category_name = p.product_categoryName left outer join OrderItemView oi on p.product_id = oi.orderItem_productId left outer join OrderView o on oi.orderItem_orderId = o.order_id left outer join CreditCardView cc on o.order_creditCardNumber = cc.creditCard_number group by ca.category_name ) t4 on ca.category_name = t4pk where t1rp1 > 6 group by t2rp1, t3rp1, t4rp1 order by g1, p2 limit 500;