目前工作中遇到的较长的SQL语句,记录一下,时常看看,其它短的就简单啦.
select id,
plat_date,
actiontype,
t9.codevalue,
submit_user,
submit_date,
feed_user,
feed_date,
t8.jgmc branch_name,
accountno,
t2.codevalue accountstat,
t3.codevalue amtype,
en_code,
en_name,
t4.codevalue account_type,
t5.codevalue account_cata,
t6.codevalue currency_code,
business_date,
file_number,
t7.codevalue limit_type,
account_limit,
actiondesc,
remark
FROM T_FEDS_ACCOUNT t1,
t_feds_appcodeparam t2,
t_feds_appcodeparam t3,
t_feds_appcodeparam t4,
t_feds_appcodeparam t5,
t_feds_appcodeparam t6,
t_feds_appcodeparam t7,
t_base_bankinst t8,
t_feds_appcodeparam t9
WHERE
t1.accountstat= t2.codenumber
and t2.codetype = '14'
and t1.amtype= t3.codenumber
and t3.codetype = '13'
and t1.account_type= t4.codenumber
and t4.codetype = '15'
and t1.account_cata= t5.codenumber
and t5.codetype = '16'
and t1.currency_code= t6.codenumber
and t6.codetype = '17'
and t1.limit_type= t7.codenumber
and t7.codetype = '12'
and t1.branch_code = t8.jgbh
and t1.submit_id = t9.codenumber
and t9.codetype = '97'
and t1.plat_date like '{$param1}' and (t1.branch_code ='{$param2}' or t1.branch_code in (select jgbh from t_base_bankinst where sjjg='{$param2}'))
order by plat_date desc,plat_time desc