My data consist of a series of request over time [:REQUEST] and responses [:RESPONSE] each with respective created date. I need only the responses within the date range I get requests. So I only want the responses to the request I got today even though I may have made responses to older request today also....e.g. I got 10 request over the past week....5 over the past two days. I responded to all 10.I need to know how many I got over the past two days and how many of THOSE I responded to. I have tried various variation of this Cypher with inconsistent results:
<MATCH (d:Dealer {email: $email})-[s:SUPPLY]->(m)
WITH d, COLLECT(toLower(m.name)) AS makeList
MATCH(r:Request)
WHERE apoc.coll.contains(makeList,toLower(r.makeVehicle))
AND r.createdAt >= $startDate AND r.createdAt <= $endDate
**above cypher collects request received **
WITH d,r, COUNT(r) AS Requests ** I need to use this count() later**
MATCH (d)-[resp:RESPONSE]->(r) I only want to look at responses to request in period above
WITH d,resp,r,Requests
MATCH (d)<-[order:ORDER]-(r) I now need to capture orders to only to those responses
WITH d,r,order, resp, COLLECT(order.paymentType) AS PaymentTypes I need a list of paymentTypes
RETURN toInteger(COUNT(Requests)), toInteger(COUNT(resp)), toInteger(COUNT(order)), PaymentTypes> I need a list of the paymentTypes
How can I create a cypher to get the result I need?