如何将我的示例查询写入codeigniter

时间:2019-06-26 10:50:12

标签: mysql codeigniter subquery

我有一个查询来查找同一表中无组和的百分比值,我已经找到了查询,但是很难实现codeigniter。有人可以帮我吗?

SELECT customer_group,sum(invoice_qty) as total,
        (sum(invoice_qty)*100/totals.tot) as persen,
        totals.tot as toti 
FROM (
        SELECT sum(invoice_qty) as tot 
        FROM report_dpms 
        WHERE sbu = 'SK Jakarta'
     ) as totals, `report_dpms` 
WHERE sbu = 'SK Jakarta' 
GROUP BY customer_group 
ORDER by SUM(invoice_qty) DESC 
LIMIT 5

0 个答案:

没有答案