Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-23-2022 03:04 PM
I can use an expression to create a custom sequence number, and give it a name with AS, and then use that name in ORDER BY. In Neo4j browser, is it possible to suppress that column in the resulting list? It needs to defined in RETURN in order to sort by it in ORDER BY, but I don't really need to see it.
03-02-2022 05:27 PM
You can do what you're looking for by not including the sequence number in the RETURN
clause. Guessing at your query for the example:
MATCH (p:Person)
WITH collect(p) AS peez, range(0,size(collect(p)) - 1) as nbrs
UNWIND nbrs AS nbr
RETURN peez[nbr] AS person
ORDER BY nbr DESC
╒═══════════════╕
│"person" │
╞═══════════════╡
│{"name":"Anne"}│
├───────────────┤
│{"name":"Dan"} │
└───────────────┘
With sequence number
MATCH (p:Person)
WITH collect(p) AS peez, range(0,size(collect(p)) - 1) as nbrs
UNWIND nbrs AS nbr
RETURN nbr, peez[nbr] AS person
ORDER BY nbr DESC
╒═════╤═══════════════╕
│"nbr"│"person" │
╞═════╪═══════════════╡
│1 │{"name":"Anne"}│
├─────┼───────────────┤
│0 │{"name":"Dan"} │
└─────┴───────────────┘
03-09-2022 02:16 PM
If I don't include the sequence number in the RETURN clause, it's not available t the ORDER BY clause.
03-09-2022 02:25 PM
Something like this:
To sort other than alphabetically:
with '<my data>' as site, '<my data value>' as param
match (o:Observation) where o.site = site and o.param = param
return
case o.env
when 'Latest' then 1
when 'Stage' then 2
when 'Load' then 3
end as seq,
o.env as env, max(o.dateTime) as dateTime, o.value as value
order by seq
I want to sort by, but not show, the "seq" column.
03-09-2022 04:39 PM
Try this:
with 'my data' as site, 'my data value' as param
match (o:Observation) where o.site = site and o.param = param
with
case o.env
when 'Latest' then 1
when 'Stage' then 2
when 'Load' then 3
end as seq,
o.env as env, max(o.dateTime) as dateTime, o.value as value
order by seq
return env, dateTime, value
Just a note, @dan.flavin_enterpris' queries do run.
All the sessions of the conference are now available online