这个查询有什么问题:
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
答案 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