Monthly Sales by SKU heading select from_unixtime(A.date_orig,'%Y%m') as yearmonth, from_unixtime(A.date_orig,'%M, %Y') as dates, A.sku, B.account_id from %%AGILE_DB_PREFIX%%invoice_item A inner JOIN %%AGILE_DB_PREFIX%%invoice B ON (A.invoice_id=B.id and billing_status=1 and (refund_status=0 or refund_status is null) and B.site_id=%%DEFAULT_SITE%%) A.site_id = %%DEFAULT_SITE%% GROUP BY yearmonth ORDER BY yearmonth DESC 0 yearmonth true true false false false Breakdown for Month: dates true Account B.account_id false SKU sku false select A.sku, sum(A.quantity) as quan, sum(A.total_amt) as amt, from_unixtime(A.date_orig,'%Y%m') as yearmonth, B.account_id from %%AGILE_DB_PREFIX%%invoice_item A inner JOIN %%AGILE_DB_PREFIX%%invoice B ON (A.invoice_id=B.id and billing_status=1 and (refund_status=0 or refund_status is null) and B.site_id=%%DEFAULT_SITE%%) A.site_id = %%DEFAULT_SITE%% GROUP BY yearmonth, sku ORDER BY amt DESC 30 yearmonth false false SKU sku Quantity quan true num,0 num,0 Amount amt dol,2 true dol,2 Account B.account_id false select A.sku, sum(A.total_amt) as amt, from_unixtime(A.date_orig,'%Y%m') as yearmonth, B.account_id from %%AGILE_DB_PREFIX%%invoice_item A inner JOIN %%AGILE_DB_PREFIX%%invoice B ON (A.invoice_id=B.id and billing_status=1 and (refund_status=0 or refund_status is null) and B.site_id=%%DEFAULT_SITE%%) A.site_id = %%DEFAULT_SITE%% GROUP BY yearmonth, sku ORDER BY amt DESC