Revenue by Card Type heading SELECT DISTINCT from_unixtime(date_orig,"%Y") as yearmonth from %%AGILE_DB_PREFIX%%invoice A inner join %%AGILE_DB_PREFIX%%account_billing B on (A.account_billing_id=B.id) A.site_id=%%DEFAULT_SITE%% and A.billing_status=1 and (A.refund_status='' OR A.refund_status is null) ORDER BY yearmonth ASC 0 Year: yearmonth true true true false false select DISTINCT UCASE(B.card_type) as card_type, count(A.id) as quan, sum(A.total_amt) as amt, from_unixtime(A.date_orig,'%Y') as yearmonth from %%AGILE_DB_PREFIX%%invoice A inner join %%AGILE_DB_PREFIX%%account_billing B on (A.account_billing_id=B.id) A.site_id = %%DEFAULT_SITE%% and B.site_id = %%DEFAULT_SITE%% and (A.refund_status='' OR A.refund_status is null) GROUP BY B.card_type ORDER BY amt ASC 30 Date yearmonth false false Card Type card_type Invoices quan true Amount amt dol,2 true dol,2 select UCASE(B.card_type) as card_type, sum(A.total_amt) as amt, from_unixtime(A.date_orig,'%Y') as yearmonth from %%AGILE_DB_PREFIX%%invoice A inner join %%AGILE_DB_PREFIX%%account_billing B on (A.account_billing_id=B.id) A.site_id = %%DEFAULT_SITE%% and B.site_id = %%DEFAULT_SITE%% and (A.refund_status='' OR A.refund_status is null) GROUP BY B.card_type ORDER BY amt ASC heading SELECT DISTINCT from_unixtime(date_orig,"%M, %Y") as yearmonth, from_unixtime(date_orig,"%Y-%m") as ordby from %%AGILE_DB_PREFIX%%invoice A inner join %%AGILE_DB_PREFIX%%account_billing B on (A.account_billing_id=B.id) A.site_id=%%DEFAULT_SITE%% and A.billing_status=1 and (A.refund_status='' OR A.refund_status is null) ORDER BY ordby ASC 0 Month: yearmonth true true true false false select DISTINCT UCASE(B.card_type) as card_type, count(A.id) as quan, sum(A.total_amt) as amt, from_unixtime(A.date_orig,'%M, %Y') as yearmonth, from_unixtime(date_orig,"%Y-%m") as ordby from %%AGILE_DB_PREFIX%%invoice A inner join %%AGILE_DB_PREFIX%%account_billing B on (A.account_billing_id=B.id) A.site_id = %%DEFAULT_SITE%% and B.site_id = %%DEFAULT_SITE%% and (A.refund_status='' OR A.refund_status is null) GROUP BY B.card_type ORDER BY ordby 30 Date yearmonth false false Card Type card_type Invoices quan true Amount amt dol,2 true dol,2 select UCASE(B.card_type) as card_type, sum(A.total_amt) as amt, from_unixtime(A.date_orig,'%M, %Y') as yearmonth from %%AGILE_DB_PREFIX%%invoice A inner join %%AGILE_DB_PREFIX%%account_billing B on (A.account_billing_id=B.id) A.site_id = %%DEFAULT_SITE%% and B.site_id = %%DEFAULT_SITE%% and (A.refund_status='' OR A.refund_status is null) GROUP BY B.card_type ORDER BY amt