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 * 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 curFinal=============
>>SET TALK OFF >>SET ECHO OFF >>SET SAFETY OFF >>PUBLIC s >>USE table1 >>local myArray(1) >>select areacode, team, count(*) from table1 group by areacode, team into array myArray >> >>lnTotal = 0 >>for i = 1 to alen(myArray, 1) >> lnTotal = lnTotal + myArray[i, 3] >>next i >> >>* Print percentajes >>if lnTotal > 0 >> ? 'areacode', 'Team', 'Count', 'Percentaje' >> for i = 1 to alen(myArray, 1) >> ? myArray[i, 1], myArray[i, 2], myArray[i, 3], myArray[i, 3] / lnTotal * 100 >> next i >> >>endif >> > >>thanks.