qq_30505667
qq_30505667
2017-11-12 05:25

oracle查询语句 变成mysql 求各位前辈指导

2
  • oracle
  • mysql

select
de.plate_number,d1.dept_name deptName, d.dept_name, de.device_name,
decode(de.tech_status,1,'完好',2,'待修',3,'待报废'), decode(de.use_status,0,'停用',1,'在用',2,'已交'),
ceil(to_date('${end_date}','yyyy-MM-dd')+1-to_date('${start_date}','yyyy-MM-dd')) - RPT_RETURN_GZTJ(de.plate_number,'${start_date}','${end_date}') goodDays,
RPT_RETURN_GZTJ(de.plate_number,'${start_date}','${end_date}') fault_time,
nvl(rpt_return_sjkd(de.plate_number,'${start_date}','${end_date}'),0) real_drive,
trunc((ceil(to_date('${end_date}','yyyy-MM-dd')+1-to_date('${start_date}','yyyy-MM-dd')) - RPT_RETURN_GZTJ(de.plate_number,'${start_date}','${end_date}'))/ ceil(to_date('${end_date}','yyyy-MM-dd')+1-to_date('${start_date}','yyyy-MM-dd'))*100,2)|| '%' good_rate,
trunc(nvl(RPT_RETURN_SJKD(de.plate_number,'${start_date}','${end_date}'),0)/RPT_RETURN_JHKD(substr(de.device_code,1,2),'${start_date}','${end_date}')*100)|| '%' LY_lV,
trunc(RPT_RETURN_CCCS(de.plate_number,'${start_date}','${end_date}')/ceil(to_date('${end_date}','yyyy-MM-dd')+1-to_date('${start_date}','yyyy-MM-dd'))*100)|| '%' SY_lV,
RPT_RETURN_CCCS(de.plate_number,'${start_date}','${end_date}') cccs,
RPT_RETURN_CCCS_SJ(de.plate_number,'${start_date}','${end_date}') sjcccs,
nvl(sum(t.run_time),0),
nvl(sum(t.run_distance),0)
from device_info_t de
left join new_sheet_t t on de.plate_number = t.plate_number and t.car_leave_time >= to_date('${start_date}','yyyy-MM-dd')
and t.car_leave_time < to_date('${end_date}','yyyy-MM-dd')+1
left join dept_info_t d on de.use_dept_code = d.dept_code
left join dept_info_t d1 on d1.dept_code = de.belong_dept_code
where de.use_dept_code IN (SELECT T.DEPT_CODE FROM DEPT_INFO_T T START WITH T.DEPT_CODE='${dept_code}' CONNECT BY PRIOR T.DEPT_ID=T.DEPT_PARENT)
and de.device_name like '%车'
and de.use_status <> 2
group by de.plate_number,d1.dept_name, d.dept_name, de.device_name,de.device_code,
decode(de.tech_status,1,'完好',2,'待修',3,'待报废'), decode(de.use_status,0,'停用',1,'在用',2,'已交')
order by de.device_name,de.plate_number

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答