Hi,
How can I also RETURN an item which doesn't exist in a list. In the case below item "2" doesn't exist. But I like still to have added to the output for instance:
{
"statusType": "2",
"nrOfCables": 0
}
Was thinking to have a WHERE clause like below but that doesn't work:
WHERE ((cables.status IN ["0", "1", "2", "3", "4", "5"]) OR (NOT (cables.status IN ["0", "1", "2", "3", "4", "5"]) ))
How to solve ?
Current query:
MATCH (cables:Cables)
WHERE cables.status IN ["0", "1", "2", "3", "4", "5"]
WITH cables.status as statusType,
count(*) as countOfCables
WITH {statusType: statusType,
nrOfCables: countOfCables} as typeData
ORDER BY typeData.statusType
return typeData
The output shows:
typeData
{
"statusType": "1",
"nrOfCables": 4
}
{
"statusType": "3",
"nrOfCables": 4
}
{
"statusType": "4",
"nrOfCables": 2
}
{
"statusType": "5",
"nrOfCables": 2
}
Creating a data set:
// 01. Delete all
MATCH (all) DETACH DELETE all;
CREATE (cable1:Cables {length:0, cableType:"Main", pulled:"Not Pulled", mainCable:"Not Routed", status:"1", connectedFrom:FALSE, connectedTo:FALSE, description:"[Lt-Supply][P]LP7421 Supply 2 Lighting"});
CREATE (cable2:Cables {length:100, cableType:"Main", pulled:"Pulled", mainCable:"Routed", status:"3", connectedFrom:FALSE, connectedTo:FALSE, description:"[Lt-Supply][P]LP7421 Supply 2 Lighting"});
CREATE (cable3:Cables {length:100, cableType:"Main", pulled:"Pulled", mainCable:"Routed", status:"3", connectedFrom:TRUE, connectedTo:FALSE, description:"[Tech-Lt][P]Power Socket"});
CREATE (cable4:Cables {length:100, cableType:"Main", pulled:"Pulled", mainCable:"Routed", status:"4", connectedFrom:TRUE, connectedTo:TRUE, description:"[Tech-Lt][P]Power Socket"});
CREATE (cable5:Cables {length:100, cableType:"Main", pulled:"Pulled", mainCable:"Routed", status:"5", connectedFrom:TRUE, connectedTo:TRUE, description:"[Crew-Lt][P]Art Light (Spare)"});
CREATE (cable6:Cables {length:0, cableType:"Main", pulled:"Not Pulled", mainCable:"Not Routed", status:"1", connectedFrom:FALSE, connectedTo:FALSE, description:"[RZ][1]24VDC GMDSS Light Red (SPARE)"});
CREATE (cable7:Cables {length:0, cableType:"Local", pulled:"Not Pulled", mainCable:"Not Routed", status:"1", connectedFrom:FALSE, connectedTo:FALSE, description:"[Lt-Supply][P]LP7421 Supply 2 Lighting"});
CREATE (cable8:Cables {length:100, cableType:"Local", pulled:"Not Pulled", mainCable:"Local", status:"3", connectedFrom:TRUE, connectedTo:TRUE, description:"[Lt-Supply][P]LP7421 Supply 2 Lighting"});
CREATE (cable9:Cables {length:100, cableType:"Local", pulled:"Pulled", mainCable:"Local", status:"3", connectedFrom:FALSE, connectedTo:TRUE, description:"[Tech-Lt][P]Power Socket"});
CREATE (cable10:Cables {length:100, cableType:"Local", pulled:"Not Pulled", mainCable:"Local", status:"4", connectedFrom:TRUE, connectedTo:FALSE, description:"[Tech-Lt][P]Power Socket"});
CREATE (cable11:Cables {length:100, cableType:"Local", pulled:"Pulled", mainCable:"Local", status:"5", connectedFrom:TRUE, connectedTo:TRUE, description:"[Crew-Lt][P]Art Light (Spare)"});
CREATE (cable12:Cables {length:100, cableType:"Local", pulled:"Pulled", mainCable:"Local", status:"1", connectedFrom:FALSE, connectedTo:FALSE, description:"[RZ][1]24VDC GMDSS Light Red (SPARE)"});