Это запрос, который мне нужно преобразовать из SQL в CodeIgniter:
SELECT b.bulan_tahun,b.kec, SUM(b.LFormal) AS LFormal, SUM(b.PFormal) AS PFormal, SUM(b.LFormal)+SUM(b.PFormal) AS SUMFormal,
SUM(b.LInformal) AS LInformal, SUM(b.PInformal) AS PInformal, SUM(b.LInformal)+SUM(b.PInformal) AS SUMInformal, SUM(b.LFormal)+ SUM(b.LInformal) AS LJumlah,
SUM(b.PFormal)+SUM(b.PInformal) AS PJumlah,SUM(b.LFormal)+SUM(b.LInformal)+SUM(b.PFormal)+SUM(b.PInformal) AS SUMJUMLAH FROM
(SELECT a.bulan_tahun,a.kec,
(CASE WHEN a.sktor_pkrjaan='FORMAL' AND a.jk='L' THEN JJK ELSE 0 END) AS LFormal,
(CASE WHEN a.sktor_pkrjaan='FORMAL' AND a.jk='P' THEN JJK ELSE 0 END) AS PFormal,
(CASE WHEN a.sktor_pkrjaan='INFORMAL' AND a.jk='L' THEN JJK ELSE 0 END) AS LInformal,
(CASE WHEN a.sktor_pkrjaan='INFORMAL' AND a.jk='P' THEN JJK ELSE 0 END) AS PInformal
FROM
(SELECT id_tki,bulan_tahun,kec, COUNT(jk) AS JJK, sktor_pkrjaan, jk
FROM tki
GROUP BY id_tki,bulan_tahun,kec, sktor_pkrjaan, jk) a
WHERE a.JJK>0) b
GROUP BY b.bulan_tahun,b.kec
Я попытался выполнить поиск в Active Record CodeIgniter, но не смог получить ответ.
Спасибо.