我的查询:
select
cue.cod_cli, sum(cue.sal_doc) as total, cue.num_doc count
from
cxc_cuedoc cue
where
sal_doc > 0 and tip_doc = '010'
group by
cue.cod_cli
预期结果
cod_cli total num_doc
--------------------------------
47474747 450,30 4
num_doc
将是给我总数的文件总数。
答案 0 :(得分:1)
我想你想要sum(cue.num_doc)
。
select cue.cod_cli, sum(cue.sal_doc) as total,
sum(cue.num_doc) as count
from cxc_cuedoc cue
where sal_doc > 0 and tip_doc = '010'
group by cue.cod_cli;
您可能需要count(*)
。如果没有样本数据,很难说清楚。