cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Doubt about clause: SET-CASE-WHEN-THEN

costa0096
Node Clone

Hi. Recently i've posted a query(then solved) that was to sum string values, and if a label was upper that value it was returned like some kind of fraudulent entity.
Here's my query:

Match (e1:ENTIDADE) -[c:CONTRATO]->(e2:ENTIDADE)
With e1, sum(tofloat(replace(replace(C.Preco,".",""),",","."))) as sumPreco
Where sumPreco >50000
Return e1 as Entity, sumPreco

Now, i want to do the same query but instead use the set clause. I've made this way:

Match (e1:ENTIDADE)-[C:Contrato]->(e2:ENTIDADE)
WITH e1, sum(tofloat(replace(replace(C.Preco,".",""),",","."))) as sumPreco
SET(
CASE
WHEN sumPreco >50000
THEN RETURN e1 as FraudulentEntity, sumPreco

but it gives me this error:


Why? The clause's contruction is bad?
Thank you all and stay safe

1 ACCEPTED SOLUTION

I've solved it.
This was the solution:

Match (eante:EntAdjudicante)-[C:CONTRATO]->(eataria:EntAdjudicataria)
WITH eante,sum(tofloat(replace(replace(C.Preco,".",""),",","."))) as sumPreco
WHERE sumPreco >50000
REMOVE eante:EntAdjudicante
SET eante:FraudulentEntity
RETURN eante

Thanks anyway

View solution in original post

3 REPLIES 3

Hello,

Your syntax is not good: https://neo4j.com/docs/cypher-manual/current/clauses/set/#set-set-a-property
What do you want to SET and what do you want to return?

I've solved it.
This was the solution:

Match (eante:EntAdjudicante)-[C:CONTRATO]->(eataria:EntAdjudicataria)
WITH eante,sum(tofloat(replace(replace(C.Preco,".",""),",","."))) as sumPreco
WHERE sumPreco >50000
REMOVE eante:EntAdjudicante
SET eante:FraudulentEntity
RETURN eante

Thanks anyway

Good job:)

No problem