SELECT `CUSTOMER_SK`, sum(`SELLING_RETAIL_AMT`) as revenue FROM `sales219` WHERE `CUSTOMER_SK` > 1 group by `CUSTOMER_SK` create table customer10000 as SELECT * FROM `customer` ORDER BY `customer`.`revenue` DESC limit 0, 10000 CREATE TABLE j_kuntz.customer AS SELECT `CUSTOMER_SK` , SUM( `SELLING_RETAIL_AMT` ) AS revenue, COUNT( DISTINCT `TRANSACTION_RK` ) AS visits FROM `sales211` WHERE `CUSTOMER_SK` >1 GROUP BY `CUSTOMER_SK`