我有一个查询来查找同一表中无组和的百分比值,我已经找到了查询,但是很难实现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