Select distinct PED.CODPESSOA, PES.NOME, (sum(PED.TOTALLIQB) over()) as TOTAL, (sum(PED.TOTALLIQB) over (partition by PED.CODPESSOA)) as TOTAL_PESSOA , ((sum(PED.TOTALLIQB) over (partition by PED.CODPESSOA)) / (sum(PED.TOTALLIQB) over()) * 100) as PERC from PEDIDO PED inner join PESSOA PES on PES.CODPESSOA=PED.CODPESSOA where PED.DATA between '01/01/2019' and '12/31/2019' and PED.SOMAFAT = 'S' and PED.TIPOMOV = 'S' and PED.TOTALLIQB > 0 order by TOTAL_PESSOA desc, PES.NOME, PED.CODPESSOA