Check for the existence and add them from 2 different files

Hi,

I have two files

file1:

ALEX
DANY
GARY
TOM
MARY
HARRIS

file2:

ALEX 3
ALEX 5
ALEX 0
ALEX 1
ALEX 0
DANY 2
DANY 3
DANY 0
DANY 0
DANY 1
GARY 20
GARY 25
GARY 3
GARY 5
GARY 0
TOM 8
TOM 7
TOM 0
TOM 5
TOM 2
TOM 1
MARY 0
MARY 0
MARY 8
MARY 12
MARY 2
MARY 1
HARRIS 5
HARRIS 6
HARRIS 12
HARRIS 18
HARRIS 13
HARRIS 20
LILY 12
LILY 13
LILY 5
LILY 8
LILY 16

What i am trying to do is for each entry in file 1 I need to count the values for the same entry in column 2 and add them up.

output:

ALEX 9
DANY 6
GARY 53
TOM 23
MARY 23
HARRIS 74

Thanks,

try:

awk '
NR==FNR { a[$1]=$1; next }
a[$1] { c[$1]+=$2;}
END { for (i in c) print i, c;}
' file1 file2 | sort
awk 'FNR==NR{c[$1]+=$2;next}{print $1,c[$1]+0}' file2 file1