'morning!
I'm noticing a weird behaviour of aliases in queries: I executed this query (notice the use of alias in the WHERE clause)
SELECT traversedElement(1).start AS stime, traversedElement(2) AS destination
FROM (TRAVERSE both('Involves') FROM #11:11052 WHILE $depth <= 2)
WHERE @rid = #11:8395
AND stime = DATE('31.10.2014 11:00:00')
and I obtained an empty result, while avoiding the use of the stime
alias in the WHERE clause causes the query to produce the right result.
SELECT traversedElement(1).start AS stime, traversedElement(2) AS destination
FROM (TRAVERSE both('Involves') FROM #11:11052 WHILE $depth <= 2)
WHERE @rid = #11:8395
AND traversedElement(1).start = DATE('31.10.2014 11:00:00')
Does anybody know what's going on? Are aliases not processed in WHERE clauses?
答案 0 :(得分:1)
@Alberto If you use an alias you can't use it immediately in where clause. You have two different ways to execute your query
1)
select from (SELECT traversedElement(1).start AS stime, traversedElement(2) AS destination
FROM (TRAVERSE both('Involves') FROM #11:11052 WHILE $depth <= 2)
WHERE @rid = #11:8395) where stime = DATE('31.10.2014 11:00:00')
2)
select start as stime,destination from (SELECT traversedElement(1).start, traversedElement(2) AS destination
FROM (TRAVERSE both('Involves') FROM #11:11052 WHILE $depth <= 2)
WHERE @rid = #11:8395 AND traversedElement(1).start = DATE('31.10.2014 11:00:00'))