Provides the SQL for collection subqueries. Moved here from PathExpressionParser to make it re-useable.