Moving the query inside summary.