ORA-00936:缺少表达式Oracle Query错误

时间:2015-04-29 10:18:11

标签: sql oracle

这个查询有什么问题:

SELECT b.DOING_BIZ_AS,
  LPAD(b.RTL_LOC_ID, 7, '0') STR_HDR_LOC_ID,
  LPAD(b.STORE_CITY,13) STR_HDR_CITY,
  LPAD(b.STATE,2) STR_HDR_STATE,
  LPAD(b.STORE_PCODE,5) STR_HDR_PCODE,
  LPAD(b.PHONE_NUMBER, 12) STR_HDR_PNO,
  LPAD(SUM(a.ITEM_CNT),7,'0') STR_TLR_ITEMCNT,
  LPAD(SUM(a.DR_AMT),11,'0') STR_TLR_DRAMT,
  LPAD(SUM(a.CR_AMT),7,'0') STR_TLR_CRAMT
FROM SIGNTR_SCH01.SIGNTR_TRANS_HDR a,
  SIGNTR_SCH01.SIGNTR_RTL_LOC b
WHERE a.RTL_LOC_ID = b.RTL_LOC_ID
AND a.RTL_LOC_ID   = 1984

1 个答案:

答案 0 :(得分:0)

至少缺少GROUP BY子句。

SELECT b.DOING_BIZ_AS,
  LPAD(b.RTL_LOC_ID, 7, '0') STR_HDR_LOC_ID,
  LPAD(b.STORE_CITY,13) STR_HDR_CITY,
  LPAD(b.STATE,2) STR_HDR_STATE,
  LPAD(b.STORE_PCODE,5) STR_HDR_PCODE,
  LPAD(b.PHONE_NUMBER, 12) STR_HDR_PNO,
  LPAD(SUM(a.ITEM_CNT),7,'0') STR_TLR_ITEMCNT,
  LPAD(SUM(a.DR_AMT),11,'0') STR_TLR_DRAMT,
  LPAD(SUM(a.CR_AMT),7,'0') STR_TLR_CRAMT
FROM SIGNTR_SCH01.SIGNTR_TRANS_HDR a,
  SIGNTR_SCH01.SIGNTR_RTL_LOC b
WHERE a.RTL_LOC_ID = b.RTL_LOC_ID
AND a.RTL_LOC_ID   = 1984
GROUP BY b.DOING_BIZ_AS,
         b.RTL_LOC_ID,
         b.STORE_CITY,
         b.STATE,
         b.STORE_PCODE,
         b.PHONE_NUMBER