|
|
|
ต้องการ sum ข้อมูลต้อง Group by อย่างไรโดยใช้ Ireport กับ Oracle SQL |
|
|
|
|
|
|
|
ตัวอย่าง SQL
Code (SQL)
select
adrrais,ADRRUE1, ADRRUE2, ADRVILL, adrcode,adriden, ADRNCLI,stmsite,STMVPA, STMVPR,STMUPR, STMCEXMVT,
artcexr ARTCODE,
sum((case when Smmttva = 0 then nvl(((smmbiiu + smmpuiu + smmdtiu + smmuaiu + smmcriu + smmpriu + smmaiiu + smmexiu) - (smmsaiu + smmdtou + smmvriu + smmcoiu)),0)
when Smmttva = 7 then nvl(((smmbiiu + smmpuiu + smmdtiu + smmuaiu + smmcriu + smmpriu + smmaiiu + smmexiu) - (smmsaiu + smmdtou + smmvriu + smmcoiu)),0)
else 0 end )) as ending,
sum((case when Smmttva = 0 then nvl(((smmbiac + smmpuac + smmdtic + smmuaac + smmcrac + smmprac + smmaiac + smmexac) - (smmsaac + smmdtoc + smmvrac + smmcoac)),0)
when Smmttva = 7 then nvl(((smmbiac + smmpuac + smmdtic + smmuaac + smmcrac + smmprac + smmaiac + smmexac) - (smmsaac + smmdtoc + smmvrac + smmcoac)),0)
else 0 end )) as ending_cost ,
pkstrucobj.get_Desc(1,artcinr,:PLANG) ART_DESC,
to_char(stmdmvt,'dd/MON/yyyy') MVT_DATE,
STMTMVT MVT_TYPE,
Pkparpostes.Get_Postlibl(1,10,1068,STMTMVT,'GB') MVT_DESC,
STMMOTF MVT_REASON,
Pkparpostes.Get_Postlibl(1,10,506,STMMOTF,'GB') MVT_REASON_DESC,
(case
when stmval > 0 then stmval
else 0
end) as IN_QTY,
(case
when stmval < 0 then stmval
else 0
end) OUT_QTY,
(case
when STMVPR > 0 then STMVPR
else 0
end) as IN_Cost,
(case
when STMVPR < 0 then STMVPR
else 0
end) OUT_Cost,
STMVPR COST_VALUE,
STMUPR UNIT_COST,
initcap(to_Char(to_date(:PDATE||'01','yyyymmdd'),'MONTH')) MONTH_LABEL,
to_numbeR(substr(:PDATE,1,4)) YEAR_LABEL
from stomvt,artul,artrac,cliadres,stomvmois,
(
SELECT OBJCINT p2
FROM STRUCREL
CONNECT BY PRIOR OBJCINT = OBJPERE AND TRUNC(CURRENT_DATE) BETWEEN OBJDDEB AND OBJDFIN
START WITH OBJPERE = :PMER AND TRUNC(CURRENT_DATE) BETWEEN OBJDDEB AND OBJDFIN
UNION
SELECT SOBCINT p2
FROM STRUCOBJ
WHERE SOBCINT = :PMER
)
where arucinl = stmcinl
and artcinr = p2
and smmcinl = stmcinl
and smmmois = to_number(to_char(to_date(:PDATE||'01','yyyymmdd'),'yyyymm'))
and smmsite = stmsite
and arucinr = artcinr
and stmval <> 0
and to_numbeR(adrncli) = stmsite
and adradre = 1
and stmsite = to_numbeR(:PSITE)
and ( artcexr = :PART or :PART = '-1')
and to_char(stmdmvt,'yyyymm') = :PDATE
Group by adrrais,ADRRUE1, ADRRUE2, ADRVILL, adrcode,adriden, ADRNCLI,stmsite,STMVPA, STMVPR,STMUPR, STMCEXMVT,
artcexr ARTCODE ,
pkstrucobj.get_Desc(1,artcinr,:PLANG) ART_DESC,
to_char(stmdmvt,'dd/MON/yyyy') MVT_DATE,
STMTMVT MVT_TYPE,
Pkparpostes.Get_Postlibl(1,10,1068,STMTMVT,'GB') MVT_DESC,
STMMOTF MVT_REASON,
Pkparpostes.Get_Postlibl(1,10,506,STMMOTF,'GB') MVT_REASON_DESC,
STMVPR COST_VALUE,
STMUPR UNIT_COST,
initcap(to_Char(to_date(:PDATE||'01','yyyymmdd'),'MONTH')) MONTH_LABEL,
to_numbeR(substr(:PDATE,1,4)) YEAR_LABEL
order by stmdmvt
Error ที่ขึ้น
ORA-00933: สิ้นสุดคำสั่ง SQL ไม่ถูกต้อง
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:
Error at Line: 138 Column: 10
Tag : Java, Oracle, iReport
|
ประวัติการแก้ไข 2017-02-10 10:25:32
|
|
|
|
|
Date :
2017-02-10 10:21:07 |
By :
นู๋ |
View :
1788 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
รบกวนผู้รู้แนะนำหน่อยนะคะ
|
ประวัติการแก้ไข 2017-02-10 10:35:39
|
|
|
|
Date :
2017-02-10 10:23:43 |
By :
นู๋ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จาก Code เหมือนจะปิด Statement พวกที่เป็น Sub Query หรือ Condition ไม่ครบครับ
|
|
|
|
|
Date :
2017-02-10 11:54:24 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|