Adding a grouping query to the sample code.