I'm not able to make the sum between qtd_itens_bought and count_count. The query runs normal, at the frequency the result is the same as the amount of items that comes from the "qtd_itens_compra". In short, I would like to add up all the items and divide by the amount of people, taking the cod_person.
select top 10 cod_pessoa as CodPessoa,
dat_compra as DataCompra,
vlr_compra as ValorCompra,
cod_transacao as CodigoTransacao,
sum(qtd_itens_compra)/count(cod_pessoa)as FrequenciaCompra
from tab_transacao
where dat_compra between '2017-08-01' and '2018-08-01'
group by cod_pessoa,
dat_compra,
vlr_compra,
cod_transacao