Adds SQL statement for aggregating list items