Monthly Revenue by Affiliateheadingselect 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%% AND (B.affiliate_id > 0 OR B.affiliate_id IS NOT NULL)GROUP BY yearmonth ORDER BY yearmonth DESC0yearmonthtruetruefalsefalsefalseBreakdown for Month: datestrueselect CONCAT(C.first_name,' ', C.last_name,' ', C.company) as affiliate_name, B.id as aid, count(A.id) 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 A
JOIN %%AGILE_DB_PREFIX%%affiliate B ON (A.affiliate_id=B.id and B.site_id=%%DEFAULT_SITE%%)
JOIN %%AGILE_DB_PREFIX%%account C ON (B.account_id=C.id and C.site_id=%%DEFAULT_SITE%%)A.site_id = %%DEFAULT_SITE%% AND (A.affiliate_id > 0 OR A.affiliate_id IS NOT NULL)
and A.billing_status=1 and (A.refund_status=0 or A.refund_status is null)GROUP BY aid ORDER BY amt DESC30yearmonthfalsefalseAffiliate IDaidAffiliate Nameaffiliate_nameInvoice Quantityquantruenum,0num,0Invoice Amountamtdol,2truedol,2