Friday, May 07, 2010
advanced query :D
select sum(case when p.thn_bangun like '%2010%' then 1 else 0 end) as jumlah, sum(case when m.jml_jam > 0 and p.status like 'active' then p.kapasitas_kw * m.jml_jam*0.8 else case when p.status like 'active' then p.kapasitas_kw * 12 * 0.8 else 0 end end) as kapasitas, substring(p.id_desa,1,2) as region, p.status, l.manfaat_listrik, sum(k.jumlah) as pendanaan from pltmh as p left join mnj_operasional as m on p.id_pltmh = m.id_pltmh left join kegiatan_detail as k on p.id_pltmh = k.id_pltmh left join pemanfaatan_listrik as l on l.id_pltmh = p.id_pltmh where k.id_kegiatan = 4 and substring(p.id_desa,1,2) = $reg and l.manfaat_listrik like 'off grid' (most advanced query, so far :P)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment