解决索引实用sql
SELECT
bs.asset_name asset_name,
CASE
ca.fund_no
WHEN 'F007' THEN
'齐商银行'
WHEN 'F008' THEN
'兰州银行'
WHEN 'F005' THEN
'大兴安岭'
WHEN 'F002' THEN
'凤凰金融'
END "fund_no_name",
ca.trans_date,
ca.last_credit_amt,
ca.lender_amt,
ca.repay_amt,
ca.repay_normal_amt,
ca.repay_compst_amt,
ca.credit_amt,
ca.planned_warrant_amt,
ca.indeed_warrant_amt,
ca.indeed_normal_amt,
ca.indeed_compst_amt,
ca.settle_amt,
ca.pre_tech_fee,
ca.last_tech_fee,
ca.increase_tech_fee,
ca.reduce_tech_fee,
ca.today_warrant_fee,
ca.today_tech_fee,
ca.planned_receive_amt,
CASE
ca.`status`
WHEN '00' THEN
'未审核'
WHEN '10' THEN
'运营初审通过'
WHEN '11' THEN
'运营初审拒绝'
WHEN '20' THEN
'财务审核通过'
WHEN '21' THEN
'财务审核拒绝'
WHEN '30' THEN
'运营复审通过'
WHEN '31' THEN
'运营复审拒绝'
END "audit_status ",
DATE_FORMAT( ca.create_time, '%Y-%m-%d %H:%i:%s' ) AS create_time,
DATE_FORMAT( ca.update_time, '%Y-%m-%d %H:%i:%s' ) AS update_time,
ca.version,
ca.remark
FROM
t_clear_warrant_detail ca
LEFT JOIN t_base_switch bs ON ca.asset_code = bs.asset_code
WHERE
ca.is_valid = 'Y'
start_transDateBegin and ca.trans_date BETWEEN DATE_FORMAT(date_add('{transDateBegin}',interval -day('{transDateBegin}')+1 day),'%Y-%m-%d') and DATE_FORMAT(last_day('{transDateBegin}'),'%Y-%m-%d') end_transDateBegin
start_fund and ca.fund_no = '{fund}' end_fund
start_asset_code and ca.asset_code in( SELECT asset_code from t_base_switch bs WHERE bs.asset_no = '{asset_code}')end_asset_code
ORDER BY ca.trans_date desc