dengan menggunakan ini juga bisa (tanpa decode)

select kd1,
CODE2,
(select sum(sls*jumlah) from testt x where x.kd1=t.kd1) SALES
from testt t where t.code2 not in ('LL')
group by kd1,code2







________________________________
Dari: Faridh Wisanggeni <[email protected]>
Kepada: [email protected]
Terkirim: Sel, 10 Agustus, 2010 10:56:36
Judul: Bls: [indo-oracle] Tanya Query Group BY

  
Cara termudah subquery

select kd1,
decode(code2,'LL',null,code2) CODE2,
(select sum(sls*jumlah) from testt x where x.kd1=t.kd1) SALES
from testt t where t.code2 not in ('LL')
group by kd1,code2

semoga bermanfaat

________________________________
Dari: Deka Oktriskorian <[email protected]>
Kepada: [email protected]
Terkirim: Sel, 10 Agustus, 2010 05:33:36
Judul: [indo-oracle] Tanya Query Group BY

para master2 sekalian.

saya mau minta tolong, maklum masih newbie. ..

saya ada query 'select kd1, code2, sum (ord*hrg) sls from table1 group by
kd1, code2'

jadi hasilnya seperti ini :

KD1    CODE2   SLS
AAC    LL          36100
AAC    TG         981000
XAC    LL          35000
XAC    DD         75000

gimana ya biar hasil nya seperti di bawah ini. :

KD1    CODE2   SLS
AAC    TG          1017100
XAC    DD          110000

jadi CODE2 'LL' otomatis 'dihilangkan' dan nilai nya di jumlahkan ke nilai
SLS yang nilai KD1 sama..

sebelumnya terima kasih jawabannya :)

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]


 



[Non-text portions of this message have been removed]

Kirim email ke