Customers

Example 1

Find everything that is connected (1st degree) to Customer with OrderedId 1:

MATCH {class: Customers, as: c, where: (OrderedId=1)}--{as: n} 
RETURN $pathelements

In the Graph Editor included in Studio, using 'RETURN $pathelements' as RETURN clause, this is the obtained graph:

Example 2

Find all Locations connected to Customer with OrderedId 1:

MATCH {class: Customers, as: customer, where: (OrderedId=1)}--{Class: Locations} 
RETURN $pathelements

In the Graph Editor included in Studio, using 'RETURN $pathelements' as RETURN clause, this is the obtained graph:

Example 3

Find all Locations connected to Customer with OrderedId 1, and their Reviews (if any):

MATCH {class: Customers, as: c, where: (OrderedId=1)}--{class: Locations, as: loc}-HasReview->{class: Reviews, as: r, optional: true} 
RETURN $pathelements

In the Graph Editor included in Studio, using 'RETURN $pathelements' as RETURN clause, this is the obtained graph:

Example 4

Find the other Customers that visited the Locations visited by Customer with OrderedId 1:

MATCH {class: Customers, as: customer, where: (OrderedId=1)}--{class: Locations, as: loc}--{class: Customers, as: otherCustomers, where: (OrderedId<>1)} 
RETURN $pathelements

In the Graph Editor included in Studio, using 'RETURN $pathelements' as RETURN clause, this is the obtained graph:

If we want to return also also their Profile names, surnames and emails:

MATCH {class: Customers, as: customer, where: (OrderedId=1)}--{class: Locations, as: loc}--{class: Customers, as: otherCustomers, where: (OrderedId<>1)}-HasProfile->{class: Profiles, as: profile} 
RETURN otherCustomers.OrderedId, profile.Name, profile.Surname, profile.Email
ORDER BY `otherCustomers.OrderedId` ASC

In the Browse Tab of Studio, using 'RETURN otherCustomers.OrderedId, profile.Name, profile.Surname, profile.Email' as RETURN clause, this is the obtained list of records (only few records are shown in the image below):

Example 5

Find all the places where Customer with OrderedId 2 has stayed:

MATCH {as: n}<-HasStayed-{class: Customers, as: c, where: (OrderedId=2)} 
RETURN $pathelements

In the Graph Editor included in Studio, using 'RETURN $pathelements' as RETURN clause, this is the obtained graph:

Example 6

Find all places where Customer with OrderedId 1 has eaten:

MATCH {as: n}<-HasEaten-{class: Customers, as: c, where: (OrderedId=1)} 
RETURN $pathelements

In the Graph Editor included in Studio, using 'RETURN $pathelements' as RETURN clause, this is the obtained graph:

Example 7

Find the 3 Customers who made more reviews:

SELECT 
  OrderedId as CustomerId,
  out("MadeReview").size() AS ReviewNumbers 
FROM `Customers` 
ORDER BY ReviewNumbers DESC 
LIMIT 3

In the Browse Tab of Studio, using the query above, this is the obtained list of records:

Example 8

Find all Orders placed by Customer with Id 2:

MATCH {class: Customers, as: c, where: (OrderedId=1)}<-HasCustomer-{class: Orders, as: o} 
RETURN $pathelements

In the Graph Editor included in Studio, using 'RETURN $pathelements' as RETURN clause, this is the obtained graph:

Example 9

Calculate the total revenues from Orders associated with Customer with Id 2:

SELECT sum(Amount) as TotalAmount 
FROM (
  SELECT expand(in('HasCustomer'))
  FROM Customers
  WHERE OrderedId=2
)

In the Browse Tab of Studio, using the query above, this is the obtained list of records:

Example 10

Find the 3 Customers who placed most Orders:

SELECT 
  OrderedId as CustomerId,
  in("HasCustomer").size() AS NumberOfOrders 
FROM Customers 
ORDER BY NumberOfOrders 
DESC LIMIT 3

In the Browse Tab of Studio, using the query above, this is the visualized result:

Example 11

Find the top 3 Countries from where Customers are from:

SELECT 
  Name as CountryName,
  in('IsFromCountry').size() as NumberOfCustomers 
FROM Countries
ORDER BY NumberOfCustomers DESC 
LIMIT 3

In the Browse Tab of Studio, using the query above, this is the obtained list of records:

results matching ""

    No results matching ""