Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT DISTINCT
- m.ucode_outlet AS ucode_grup,
- m.kode_outlet AS kode_grup,
- ROUND(SUM(CASE
- WHEN tot.ucode_jns_brg = '40004' THEN tot.tot_qty
- ELSE 0
- END),
- 2) AS 'qty_Jeruk',
- ROUND(IFNULL(SUM(CASE
- WHEN tot.ucode_jns_brg = '40004' THEN tot.tot_qty
- ELSE 0
- END) / SUM(tot.tot_qty) * 100,
- 0),
- 2) AS 'psn_Jeruk',
- ROUND(SUM(CASE
- WHEN tot.ucode_jns_brg = '40005' THEN tot.tot_qty
- ELSE 0
- END),
- 2) AS 'qty_Jeruk_Multi',
- ROUND(IFNULL(SUM(CASE
- WHEN tot.ucode_jns_brg = '40005' THEN tot.tot_qty
- ELSE 0
- END) / SUM(tot.tot_qty) * 100,
- 0),
- 2) AS 'psn_Jeruk_Multi',
- ROUND(IFNULL(SUM(tot.tot_qty), 0), 2) AS total,
- ROUND(IFNULL(SUM(tot.tot_qty) / SUM(tot.tot_qty) * 100,
- 0),
- 2) AS total_psn
- FROM
- tb_m_outlet m
- LEFT OUTER JOIN
- tp_m_tot_survey tot ON tot.kode_grup = m.kode_outlet
- AND tot.id_proc = 'C9C48EF838B76B415266C553B7FC6ECC'
- WHERE
- m.ucode_div LIKE '%%'
- AND m.kode_outlet LIKE '%'
- AND m.nama_outlet LIKE '%'
- GROUP BY m.ucode_outlet , m.kode_outlet , m.nama_outlet
- ORDER BY m.kode_outlet
- LIMIT 0 , 25
Advertisement
Add Comment
Please, Sign In to add comment