The standard JCR-SQL2 grammar does not support subqueries. But subqueries are such a useful feature, so ModeShape supports using multiple subqueries within a single query. In fact, subqueries are nothing more than a QueryCommand, which if you'll remember is the top-level rule in ModeShape's grammar. That means that subqueries can be any query, and you can even include subqueries within a subquery!