Read stats from database and calculate