agensgraph
agensgraph copied to clipboard
ERROR: syntax error at or near "::"
i tried to follow the below example for my case to type cast a value MATCH (n:dev) WHERE n.year::int < (SELECT year FROM history WHERE event = 'AgensGraph') RETURN properties(n) AS n;
MATCH (po: p_order) WHERE (po.b_amount::int) < (SELECT amt FROM master WHERE v = '3') RETURN properties(po) AS p_order LIMIT 10;
ERROR: syntax error at or near "::" LINE 2: WHERE (pu_o.buy_amount::int) < (SELECT amt
please share an example to convert to integer...
Hi @VinACE You can use to_jsonb() function.
e.g.) MATCH (po: p_order) WHERE (po.b_amount) < to_jsonb((SELECT amt FROM master WHERE v = '3')) RETURN properties(po) AS p_order LIMIT 10;
you answer return results, good, but I need to compare against the integer value, WHERE po.b_amount::int po.b_amount is in "123" string type. also the results that I am getting are invalid as its is comparing to string i guess, I am still validating the way I am forming the query. please have your input as well.
or how to cast WHERE (po.b_amount) as value1 -- to integer and compare with another value2. the below example,
MATCH (po: p_order) WHERE (po.b_amount) < 1000 RETURN po;
Return in correct answers less and greater than 1000 as i think its comparing to strings. without the type cast. Appreciate your help
@VinACE You can use int4(), int8() function, too.
e.g.) MATCH (po: p_order) WHERE int4(po.b_amount) < (SELECT amt FROM master WHERE v = '3') RETURN properties(po) AS p_order LIMIT 10;