From: | Raghavendra <raghavendra(dot)rao(at)enterprisedb(dot)com> |
---|---|
To: | plasmasoftware net <administrator(at)plasmasoftware(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: HELP, how to make this query. |
Date: | 2012-01-15 20:35:56 |
Message-ID: | CA+h6Ahg+rK41XXM7kVp3x2fXEPW1gY7qDeyBm-TRRD1KN8-1cw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sun, Jan 15, 2012 at 12:17 PM, plasmasoftware net <
administrator(at)plasmasoftware(dot)net> wrote:
> *select j.kode_barang kode_barang,j.isi_Satuan from J_master_barang j **order
> by j.kode_barang asc*
> *display *
> kode isi
> 00000000000001 24
> 00000000000001B 12
> 00000000000001C 1
>
> i want to make that become when i select my table.how to make this.
>
> kode isi_A isi_B isi_C
> 00000000000001 24 12 1
>
I think you have to use crosstab, you can try this out...
select '000000000001' as Kode, sum(case when j.kode_barang='A' then isi
else 0 end) as isi_A,
sum(case when
j.kode_barang='B' then isi else 0 end) as isi_B,
sum(case when
j.kode_barang='C' then isi else 0 end) as isi_C from j_master_barang;
---
Regards,
Raghavendra
EnterpriseDB Corporation
Blog: http://raghavt.blogspot.com/
From | Date | Subject | |
---|---|---|---|
Next Message | David Waddy | 2012-01-15 21:20:08 | Re: How to return latest results without a polygon intersect? |
Previous Message | Adrian Klaver | 2012-01-15 19:40:22 | Re: -devel files |