首页 > 代码库 > sql语句截取字符串
sql语句截取字符串
case when left(t5.name,2)=‘20‘ then substring(t5.name,9,2) else substring(t5.name,7,2) end GD
截取前1~10位数字 ac17072408
select substring(name,0,11) from profin_application;
name=ac1707240801
select substring(name,0,11) from profin_application;
select left(name,10) from profin_application;
select t1.name ,timeadd(‘hour‘,8,t1.date),t3.name_template ,left(t3.name_template,3) ,substring(t3.name_template,6,3) 号,t4.material ,t4.cust_spec ,
t5.name ,case when left(t5.name,2)=‘20‘ then substring(t5.name,3,6) else left(t5.name,6) end pp,case when left(t5.name,2)=‘20‘ then substring(t5.name,9,2) else substring(t5.name,7,2) end GD ,right(t5.name,3) ,t6.name ,t8.name ,t2.lqty
from mrp_production_report t1
left join mrp_production_report_line t2 on t1.id=t2.line_id
left join product_product t3 on t2.lproduct_id=t3.id
left join product_template t4 on t3.product_tmpl_id=t4.id
left join mrp_production_report_lot t5 on t5.id=t2.lot_id
left join mrp_routing_workcenter t6 on t6.id=t2.lprocedure
left join res_users t7 on t7.id=t2.lemployee
left join res_partner t8 on t8.id=t7.partner_id
where t2.lstate=2 and t6.name=‘分选‘ or t6.name=‘包装‘ and t1.company_id=4 and t1.date>=‘${sd} 0:00:00‘ and t1.date<=‘${ed} 23:59:59‘
sql语句截取字符串