Reputation: 59
My query:
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
Expected result
cod_cli total num_doc
--------------------------------
47474747 450,30 4
The num_doc
would be the total of number of documents that give me the total.
Upvotes: 1
Views: 35
Reputation: 1271151
I think you want 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;
It is possible that you want count(*)
instead. Without sample data it is hard to tell.
Upvotes: 1