This one was a bit challenging, as structure of the ClearSilver template did not translate to a well formed document.
The ordering of the groups is currently broken.
Also note that the rendering of the results is done in a separate document (query_view.html) so that the !TicketQuery macro will later be able to reuse it.