Grouping and summing data through unix

Hi everyone,

I need a help on Unix scripting.

I have a file is like this

Date Amt

20071205 10
20071204 10
20071203 200
20071204 300
20071203 400
20071205 140
20071203 100
20071205 100
20071205 10
20071205 300
20071203 10
20071204 100
20071204 100
20071205 700

I want to add all the Amt for a particular date and Return the Date having max amt.

So here is the consolidated total for individual dates.

20071203 710
20071204 510
20071205 1260

The script should return 20071205 for the above input since it has the max total amt

Can anyone provide the Unix shell script for the above requirement.

Thanks,
Charan.

awk '{
	x[$1] += $2
	if (x[$1] > max) {
		max = x[$1]
		dt = $1
		} 
} END {
	print dt
}' data

For more than one entry with amt == max:

awk '{
	x[$1] += $2
	if (x[$1] > max) {
		max = x[$1]
		} 
} END {
	for (mdt in x)
		if (x[mdt] == max)
			print mdt
}' data