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.

How to get multiple values for 1 property in return clause of cypher

Hello Team ,

I need a help in knowing logic for getting multiple values for 1 property name ( ENB_NAME ) calculated on the some formula in return statement.
PROPERTY Names used are:

  1. LTEANT_CELL_NUMBER
    2.SEC_LTEANT_CELL_NUMBER
    3.ENB_NAME

For example
formula for calculating
ENB_NAME = 'cNum'+LTEANT_CELL_NUMBER
ENB_NAME = 'cNum'+ SEC_LTEANT_CELL_NUMBER

OUTPUT:
ENB_NAME = > cNum20
ENB_NAME = > cNum9

Regards
Akshat

4 REPLIES 4

intouch_vivek
Graph Steward

If you are testing based on the null value of then try below LTEANT_CELL_NUMBER /SEC_LTEANT_CELL_NUMBER then you can try below. Else you can can apply any logic based on the requirement

RETURN ENB_NAME= CASE WHEN (LTEANT_CELL_NUMBER is null) THEN 'cNum'+'LTEANT_CELL_NUMBER' WHEN ( SEC_LTEANT_CELL_NUMBER is null ) THEN 'cNum'+'SEC_LTEANT_CELL_NUMBER' END

It may be even easier to leverage the coalesce() function, which chooses the first non-null value:

RETURN 'cNum' + coalesce(LTEANT_CELL_NUMBER, SEC_LTEANT_CELL_NUMBER) as result

If this isn't what you're asking for, then you may need to provide more details as to what you're doing, an example of your data and attempted queries so far may help.

Hi Andrew ,

Thanks for your efforts.

But My case is " 1 Property name ( ENB_NAME ) needs to have 2 different values on the basis of 2 other peroperties ( LTEANT_CELL_NUMBER & SEC_LTEANT_CELL_NUMBER ) in return statement".

For example if LTEANT_CELL_NUMBER = 5 & SEC_LTEANT_CELL_NUMBER = 10 then value of should be
ENB_NAME = cNum5
ENB_NAME = cNum10

Regards
Akshat

I think you need to explain more. A variable cannot have multiple values simultaneously, unless you want to represent it as a list of values. Is that what your'e after?

If you want to return one value in one situation, and another value in another situation, then you can use CASE expressions for this.

A more complete example of desired input and desired output (using Cypher, if possible!) would help.