add some SQL code

average,minimum, maximum and sum