sQL – C14

eMmm catetan kecil hari ini yah ini..

C14 – sQL[1]

Jadi ini perintah buat select tgl, trus ngejumlahin per status id, total kesuluruhan dari tableA dimana produk id sama dengan 1.

select to_char(tgl,’YYYYmmdd’) tgl,
sum(decode(status_id,0,1)) st0,
sum(decode(status_id,2,1)) st2,
count (*) jml_total
from tableA
where prod_id=’1′
group by To_char(tgl_klm,’YYYYmmdd’)

C14 – sQL[2]

select user_id, sum(st0) as jc0 , sum (jk0) as mo0, sum (st2) as jc2,
sum (jk2)as mo2, sum (jml_total) as jt, sum(jk0+jk2) as mot
from (
select distinct
sum(decode(a.status_id,0,1)) st0,
sum(decode(a.status_id,2,1)) st2,
sum(decode(a.status_id,0,a.jml_klaim)) jk0,
sum(decode(a.status_id,2,a.jml_klaim)) jk2,
b.user_id, count (*) jml_total
from tableA a, tableB b
where a.user_id=b.user_id and prod_id=’1′
group by user_id, jml_klaim
)
group by user_id

eMmm special thx buat pa khaidarπŸ˜‰ .Dah ah segitu dulu, mauu maksi ahh laper…πŸ˜€

5 thoughts on “sQL – C14

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s