I have the following in Confluence:
{panel}
Hello World 1
{panel}
{sql-query:datasource=DS|output=wiki|table=false|macros=true}
select '\{panel\}\\' from dual
{sql-query}
{sql-query:datasource=DS|output=wiki|table=false|macros=true}
select 'Hello World 2\\' from dual
{sql-query}
{sql-query:datasource=DS|output=wiki|table=false|macros=true}
select '\{panel\}' from dual
{sql-query}
The first panel (Hello World 1) displays correctly. The second panel (Hello World 2) does not. See output below.

How do I get Confluence to evaluate the wiki markup in the data that is returned from the SQL?
I have tried enclosing everything in a run macro e.g.
{run:hideParameters=true|hideRun=true|autoRun=true}
...
{run}
but this does not seem to have any effect.
After some hair pulling, and thanks in part to the information provided in @Steffen’s answer, I found the following solution:
A bit painful having to construct it all in one query but this gives the desired result.