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.

clem
Graph Steward

I have a couple of suggestions to improve the documentation.

  1. Add some interesting numeric fields to the Movie DB, such as Cost and BoxOffice.

  2. I figured out an interesting example using SubQuery. Cost of a movie is many digits and varies a lot, so it's a bit hard to look at without formatting. But if you format the Cost as a string, then it won't sort numerically. With Subqueries, you can do a sort of the Cost as Numeric and in the subsequent query, drop the Numeric column (which is ugly but accurate.)

CALL{
   MATCH (m:Movie)
   WITH m.title AS Title,
         m.cost AS CostNumber, // cost as numeric so we can sort
         apoc.number.format(m.cost, '$#,###') AS Cost // as a formatted string
         RETURN title, Cost, CostNumber  ORDER BY CostNumber  DESC  // ordered by Numeric
}
RETURN Title, Cost limit 100  // CostNumber is dropped
1 Comment

You don't need a subquery for that

ORDER BY can sort by any fields that are visible to the clause

 MATCH (m:Movie)
 RETURN m.title AS Title,
     apoc.number.format(m.cost, '$#,###') AS Cost // as a formatted string
 ORDER BY m.cost  DESC