Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $query = '(SELECT SUM(sd.turnov) summ, nid FROM ( ' .
- 'SELECT ' .
- 'pt.module AS m_type, ' .
- 'CASE pt.module ' .
- 'WHEN "pg_roboxchange" THEN SUM(cfos.field_order_sum_value) * %d ' .
- 'WHEN "wallet_one" THEN SUM(cfos.field_order_sum_value) * %d ' .
- 'WHEN "pg_account" THEN SUM(cfos.field_order_sum_value) * %d ' .
- 'END turnov, ' .
- 'cfoc.field_order_coupon_nid_nid nid ' .
- 'FROM content_field_order_coupon_nid cfoc ' .
- 'JOIN content_field_order_sum cfos ON cfos.nid = cfoc.nid ' .
- 'JOIN pgapi_transaction_purchases ptp ON ptp.nid = cfos.nid ' .
- 'LEFT JOIN pgapi_transaction pt ON ptp.txnid = pt.txnid ' .
- 'LEFT JOIN pgapi_transaction pt1 ON ptp.txnid = pt1.txnid AND pt1.module LIKE "pg_roboxchange" ' .
- 'LEFT JOIN pgapi_transaction pt2 ON ptp.txnid = pt2.txnid AND pt2.module LIKE "wallet_one" ' .
- 'LEFT JOIN pgapi_transaction pt3 ON ptp.txnid = pt3.txnid AND pt3.module LIKE "rbs" ' .
- 'LEFT JOIN pgapi_transaction pt4 ON ptp.txnid = pt4.txnid AND pt4.module LIKE "pg_account" ' .
- 'LEFT JOIN pgapi_transaction pt5 ON ptp.txnid = pt5.txnid AND pt5.module LIKE "comepay" ' .
- 'LEFT JOIN pgapi_transaction pt6 ON ptp.txnid = pt6.txnid AND pt6.module LIKE "e_gateway" ' .
- 'GROUP BY m_type, nid ' .
- ') sd ' .
- 'WHERE 1 ' .
- 'GROUP BY nid)';
Add Comment
Please, Sign In to add comment