Guest User

Untitled

a guest
Feb 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.15 KB | None | 0 0
  1. (SELECT SUM(sd.turnov) summ, nid FROM (
  2.   SELECT
  3.   pt.module AS m_type,
  4.   CASE pt.module
  5.    WHEN "pg_roboxchange" THEN SUM(cfos.field_order_sum_value) * 0.05
  6.    WHEN "wallet_one" THEN SUM(cfos.field_order_sum_value) * 0.03
  7.    WHEN "pg_account" THEN SUM(cfos.field_order_sum_value) * 0.04
  8.   END turnov,
  9.   cfoc.field_order_coupon_nid_nid nid
  10.   FROM content_field_order_coupon_nid cfoc
  11.   JOIN content_field_order_sum cfos ON cfos.nid = cfoc.nid
  12.   JOIN pgapi_transaction_purchases ptp ON ptp.nid = cfos.nid
  13.   LEFT JOIN pgapi_transaction pt ON ptp.txnid = pt.txnid
  14.   LEFT JOIN pgapi_transaction pt1 ON ptp.txnid = pt1.txnid AND pt1.module LIKE "pg_roboxchange"
  15.   LEFT JOIN pgapi_transaction pt2 ON ptp.txnid = pt2.txnid AND pt2.module LIKE "wallet_one"
  16.   LEFT JOIN pgapi_transaction pt3 ON ptp.txnid = pt3.txnid AND pt3.module LIKE "rbs"
  17.   LEFT JOIN pgapi_transaction pt4 ON ptp.txnid = pt4.txnid AND pt4.module LIKE "pg_account"
  18.   LEFT JOIN pgapi_transaction pt5 ON ptp.txnid = pt5.txnid AND pt5.module LIKE "comepay"
  19.   LEFT JOIN pgapi_transaction pt6 ON ptp.txnid = pt6.txnid AND pt6.module LIKE "e_gateway"
  20.   GROUP BY m_type, nid
  21. ) sd
  22. WHERE 1
  23. GROUP BY nid)
Add Comment
Please, Sign In to add comment