Search this documentation
{sql-query:datasource=myDS} select * from SPACES {sql-query}