Hi, I'm having a query with a sub-query which selects the next relevant item of the main query in the same collection but I always get an empty result here
SELECT
id,
Time AS Time1
(
SELECT
sub.Time
FROM A AS sub
WHERE
sub.value="Event" AND
sub.Time2 > main.Time1 AND
sub.state BETWEEN 0 AND 2
ORDER BY sub.Time
LIMIT 1
) AS Time2
FROM A AS main
WHERE
value="Event" AND
state BETWEEN 3 AND 6
ORDER BY Time1 ASC
The sub-query alone runs perfectly fine. Wondering if there's any constraint running a sub-query or what else could be wrong?