AWK script to create max value of 3rd column, grouping by first column

Hi,

I need an awk script (or whatever shell-construct) that would take data like below and get the max value of 3 column, when grouping by the 1st column.

clientname,day-of-month,max-users
-----------------------------------
client1,20120610,5
client2,20120610,2
client3,20120610,7
client4,20120610,9
client5,20120610,2
client1,20120611,8
client3,20120611,4
client4,20120611,4
client6,20120611,9

and get results like:

clientname,max-monthly-users
-----------------------------
client1,8
client2,2
client3,7
client4,9
client5,2
client6,9

The column-header lines are not required, but I thought would make example more concrete.

Thanks-In-Advance For any help!

Hi,
Try this one,

awk 'BEGIN{FS=",";}{if(a[$1]<$3){a[$1]=$3;}}END{for(i in a){print i","a;}}' file|sort -t',' -k1,1

if you are using gawk, make you of asort function to sort the array a and ignore the sort cmd..
Cheers,
Ranga:-)

Try this ,

sort -t"," -k1,1 -k3,3nr Filename | awk -F"," '!a[$1]++'

Another try..

awk -F, 'a[$1]<$3{a[$1]=$3} END {for (i in a){print i FS a}}' file | sort