SELECT
customer_id,
count(*) num
FROM
uic_contract
GROUP BY
customer_id
ORDER BY
num desc
SELECT
uea.energy_id,
uep.prod_name,
sum( uea.cost_num ) num
FROM
uic_energy_account uea
LEFT JOIN uic_energy_prod uep ON uep.id = uea.energy_id
WHERE
uea.is_deleted = 0
GROUP BY
uea.energy_id
标签:uic,energy,uea,uep,字段,num,SQL,id,统计
From: https://www.cnblogs.com/yqcg/p/17695444.html