嗨,我是该网站的新手,对 SQL(WinSQL)相当陌生。我正在尝试使用 case/when 来获取一些数据,但我遇到了语法错误。
select emp_id,
a.itm_num,
a.cont_num,
a.wrk_asgn
(case when c.case_qty > 0 then a.qty_actual/c.case_qty else 0 end as cartons_cp,
(case_len * case_wid * case_hgt) as cube_vol,
substr(dt_tm_start,12,2) as hr,
vehicle_class,
vehicle_type)
from 'catalyst'.trhpick a
inner Join 'catalyst'.item b
on a.itm_num = b.itm_num
inner Join 'catalyst'.itemconfig c
on b.itm_num = c.itm_num and b.def_config_seq = c.itm_conf_seq
where wrk_fnc_code = 110 and a.dt_tm_end between '2017-07-01 00:00:00' and '2017-08-24 23:59:59' and a.cont_num <> 0
group by 1,2
order by emp_id,vehicle_class