Is it possible to create statements that contain subqueries? I have not found anything about it in the docs or in the forums.
Let’s say I have this query:
SELECT COUNT(*) FROM it d WHERE d.type = 'SR_OFFER' AND d.status = 'CREATED' AND d.id IN ( SELECT RAW lockedItemId FROM it WHERE type = 'LOCK' )
Using the Java SDK’s DSL, the outer query would look something like this:
Statement statement = select("count(*)") .from(bucketName) .where( x("type").eq(x("$type") .and(x("status").eq(x("$fromStatus")))) );
I’m to trying to figure out how to add the AND […] IN clause where the expression is the subquery.
For the moment I’ll try to workaround it by performing two queries. First, the subquery to get the collection of IDs; second the outer query with the result of the previous one in the IN clause as JSONArray.