Added another test for query having grouping by referenced resource.