AGE does not support SQL being directly written in Cypher. However with user defined functions you can write SQL queries and call them in a cypher command.
Developer's Note:Void and Scalar-Value functions only. Set returning functions are not currently supported.
Create Function
CREATE OR REPLACE FUNCTION public.get_event_year(name agtype) RETURNS agtype AS $$SELECT year::agtypeFROM history AS hWHERE h.event_name = name::textLIMIT 1;$$ LANGUAGE sql;
Query
SELECT * FROM cypher('graph_name', $$MATCH (e:event)WHERE e.year < public.get_event_year(e.name)RETURN e.name$$) as (n agtype);
Results
| name |
| “Apache Con 2021” |
| 1 row |
