select areacode, team, count(*) as TeamCount from table1 ; group by areacode, team into cursor curTeamCount select areacode, count(*) as AreaCount from table1 ; group by areacode into cursor curAreaCount select curTeamCount.areacode, team, TeamCount, ; AreaCount, TeamCount/AreaCount*100 as Percentage ; from curTeamCount inner join curAreaCount on ; curTeamCount.areaCode = curAreaCount.areaCode into cursor curFinal go top in mycursor scan repl randomkey with rand(-1) endscan index on randomkey tag randomkey set order to randomkey go top * Close cursors, which are no longer needed use in curAreaCount use in curTeamCount ? 'areacode', 'Team', 'Count', 'Percentaje' select curFinal && our final result with all information scan ? AreaCode, Team, TeamCount, Percentage endscan use in curFinalthanks.