Banner

 

12 - Graph Databases
Skill Builders

List those shares where the value of the holding exceeds one million.

MATCH (s:Stock)
WHERE s.Price*s.Qty > 1000000
RETURN s.Firm AS Firm, round(s.Price*s.Qty) AS Value;

Report by nation the total value of dividends.

MATCH (n:Nation)-[:LISTS]->(s:Stock)
WITH n, round(sum(s.Div*s.Qty*n.ExchRate)) as Dividends
RETURN n.Nation AS Nation, Dividends;

Report all red items that have not been sold.

MATCH (s: Sale)-[:CONTAINS]->(i:Item {ItemColor: 'Red'})
WITH COLLECT (DISTINCT i.ItemNo) AS SoldItems
MATCH (i: Item)
WHERE i.ItemColor = 'Red' AND NOT (i.ItemNo IN SoldItems)
RETURN DISTINCT i.ItemName AS Item, i.ItemType AS Type;

This page is part of the promotional and support material for Data Management (sixth edition) by Richard T. Watson
For questions and comments please contact the author

Date revised: 05-Jan-2020