<pre name="code" class="sql">SELECT
*
FROM
DWF.F_EVT_EXTR_FINANCE_BOOK a
LEFT JOIN
dwf.f_extc_finance_para b ON a.product_no = b.product_no
LEFT JOIN
dwm.b_m_sys_branch c ON a.SIGN_ORG = c.org_id
SELECT
c.userNick, a.status, b.name, d.investBalance, a.otherinfo
FROM
ClientCoupon a
LEFT JOIN
Coupon b ON a.couponSn = b.sn
LEFT JOIN
Client c ON a.Clientsn = c.sn
LEFT JOIN
(SELECT
clientSn, SUM(investBalance) AS investBalance
FROM
ClientInvestOrder
WHERE
createdTime >= '2015-11-11 00:00:00'
AND createdTime <= '2015-11-13 23:59:59'
GROUP BY clientSn) d ON c.sn = d.clientSn
WHERE
a.clientSn IS NOT NULL
ORDER BY c.userNick