Search code examples
sqlorientdb

OrientDB using LET values in subQuery


How can you use a LET temporary variable inside the Where clause in an OrientDB SQL subQuery.

Here is the context in wich I'm trying to use it.

select *, $t.d from Currency 
   let $t = (select createdDate.asLong() as d from 13:1) 
where createdDate.asLong() >= $t.d and  @rid <> #13:1 
order by createdDate ASC

The validation in the where statement for the dates does not work. The subQuery actually works on its own. The Query works as well when replacing $t.d with the result from the subQuery.


Solution

  • The $t.d is an array so you are comparing something like createdDate.asLong() >= [1234599]

    You have to do this: createdDate.asLong() >= $t[0].d