SQL基本问题

时间:2017-07-06 07:55:08

标签: sql

   select x_pick.prod_code, x_order.order_state, x_pick.pick_state, x_pick.pick_qty, x_pick.pick_location, x_order.wave_id, x_prod.normal_pick_area, x_apr_loc.location, x_order.reqd_despatch_time, x_prod.bncd_awkward_item, sub1.LOC_COUNT
from x_pick, x_order, x_prod, x_apr_loc,

(select X_PICK.prod_CODE, COUNT(DISTINCT( X_APR_LOC.LOCATION)) AS LOC_COUNT
from X_APR_LOC, X_PICK
where X_APR_LOC.prod_CODE (+) = X_PICK.prod_CODE
group by X_PICK.prod_code) sub1,

(select x_prod.normal_pick_area,x_pick.pick_location,
(case when  x_prod.normal_pick_area = 'TP' then 'Miniload'
when x_prod.normal_pick_area = 'MTP' then 'Miniload'
when x_prod.normal_pick_area = 'PL' then 'Pallet Live'
when x_prod.normal_pick_area = 'HLOP' then 'HLOP'
when x_prod.normal_pick_area = 'STILLAGE' then 'High Value'
when x_prod.normal_pick_area = 'ZA' then 'Aerosol'
when x_prod.normal_pick_area = 'ZH' then 'Haz Shed'
when x_prod.normal_pick_area = 'APR' and substr(x_pick.pick_location,3,2) < 22 and x_prod.bncd_awkward_item = 'YES'  then 'APR Awkward'
when x_prod.normal_pick_area = 'APR' and substr(x_pick.pick_location,3,2) < 22 and x_prod.bncd_awkward_item = 'NO'  then 'APR'
when x_prod.normal_pick_area = 'APR' and substr(x_pick.pick_location,3,2) > 21 and x_prod.bncd_awkward_item = 'NO'  then 'APR 2'
when x_prod.normal_pick_area = 'APR' and substr(x_pick.pick_location,3,2) > 21 and x_prod.bncd_awkward_item = 'YES'  then 'TD1'
else 'Unknown' end) from x_pick) area,


where x_pick.prod_code  (+) = sub1.prod_code
and x_pick.prod_code = x_apr_loc.prod_code (+)
and x_pick.prod_code = x_prod.prod_code
and x_pick.order_id = x_order.order_id
and x_pick.pick_state in('RESERVED','WAIT REPLEN','STARTED')
and x_order.order_state in('RESERVED','STARTED')

更大查询的一部分。最初我收到一个无效的parathensis消息,我可以摆脱这个,但他们得到无效的标识符错误消息,即使我使用的所有字段都被调用。我对SQL很陌生,所以任何帮助都会很棒!。

2 个答案:

答案 0 :(得分:0)

请使用下面有两个问题首先需要在x_item之后的pick_location后添加逗号将在列名后面,希望它也可以在你身边工作

JsonResponse {#461 ▼
  #data: "{"error":false,"code":200,"message":"Image was deleted!"}"
  #callback: null
  #encodingOptions: 0
  +headers: ResponseHeaderBag {#459 ▶}
  #content: "{"error":false,"code":200,"message":"Image was deleted!"}"
  #version: "1.0"
  #statusCode: 200
  #statusText: "OK"
  #charset: null
  +original: array:3 [▶]
  +exception: null
}

答案 1 :(得分:0)

<c:forEach var="department" items="${departmentHash}">
    Country: ${department.key}  - Capital: ${department.value}
</c:forEach>

这应该解决它。