Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Neo4j Cookbook

You're reading from   Neo4j Cookbook Harness the power of Neo4j to perform complex data analysis over the course of 75 easy-to-follow recipes

Arrow left icon
Product type Paperback
Published in May 2015
Publisher
ISBN-13 9781783287253
Length 226 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ankur Goel Ankur Goel
Author Profile Icon Ankur Goel
Ankur Goel
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Getting Started with Neo4j FREE CHAPTER 2. Connecting to Neo4j 3. The Cypher Query Language 4. Data Modeling and Leveraging with Neo4j 5. Mining the Social Treasure 6. Developing Location-based Services with Neo4j 7. Visualization of Graphs 8. Industry Usages of Neo4j 9. Neo4j Administration and Maintenance 10. Scaling Neo4j Index

Changing the order of results with Cypher


Cypher is similar to SQL, where the order of the results can be changed using the ORDER BY clause, both in ascending and descending order. In this recipe, we will learn the use of the ORDER BY clause using the instance of the graph we have created.

Getting ready

To work through this recipe, you will need to create the nodes and relationships for which data has been provided with the code files.

How to do it...

We have divided this recipe into the following problem sets:

  • ORDER BY on numerical value: Let's get the delay times of the most delayed flights, along with the flight number and reason for delay:

    MATCH (f)-[r:`DELAYED_BY`]->(x) RETURN f.flight_number,r.time,x.name ORDER BY r.time DESC

    The following screenshot shows the Neo4j console depicting the result of the late flight time Cypher query:

  • ORDER BY on unicode strings: Let's get all the airports in ascending order by name:

    MATCH (f)-[r:ORIGIN]->(x) RETURN DISTINCT x.name ORDER BY x.name
  • ORDER BY...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $24.99/month. Cancel anytime