Hi. I’m very new to NEO4J and Graph Database. Very Strong Relational and SQL experience. Sorry if this is a simple question.
Node label description
DateRun
• Date Value of an Event
TimeRun
• Time of Day Event happen on a Day (Also has property to make it unique from other TimeRun)
Number
• Numbers (1 – 80) that are related to a TimeRun. 1-->n numbers are related to aTimeRun
The Path
(num:Number ) -[:number_on]- (tr:TimeRun) - [:time_on] - (dr:DateRun )
I issue the following statement and runs as expected.
with ['04/07/2020','04/08/2020'] as fd
match (num:Number ) -[:number_on]- (tr:TimeRun) - [:time_on] - (dr:DateRun )
where dr.value in fd
with dr as DATE_RUN, num.value as NUMBER, collect(num.value) as nc
return DATE_RUN.value, NUMBER, size(nc) as COUNT
order by DATE_RUN, NUMBER, size(nc)
The statement takes a DateRun and counts of the number of times a number is used on that date. (it does not factor the time on the date. Just the Date)
A sample of the out is:
╒════════════════╤════════╤═══════╕
│"DATE_RUN.value" │"NUMBER"│"COUNT" │
╞════════════════╪════════╪═══════╡
│"04/08/2020" │"01" │39 │
├────────────────┼────────┼───────┤
│"04/08/2020" │"02" │42 │
├────────────────┼────────┼───────┤
│"04/08/2020" │"03" │37 │
├────────────────┼────────┼───────┤
│"04/08/2020" │"04" │55 │
├────────────────┼────────┼───────┤
│"04/08/2020" │"05" │33 │
├────────────────┼────────┼───────┤
│"04/08/2020" │"06" │45 │
├────────────────┼────────┼───────┤
│"04/08/2020" │"07" │50 │
├────────────────┼────────┼───────┤
│"04/07/2020" │"01" │41 │
├────────────────┼────────┼───────┤
│"04/07/2020" │"02" │44 │
├────────────────┼────────┼───────┤
│"04/07/2020" │"03" │46 │
├────────────────┼────────┼───────┤
│"04/07/2020" │"04" │45 │
├────────────────┼────────┼───────┤
│"04/07/2020" │"05" │46 │
└────────────────┴────────┴───────┘
Is it possible to Pivot the output above to look like the sample output below?
Number 4/8/2020 4/7/2020
01 39 41
02 42 44
03 37 45
04 55 45
05 33 46
06 45 41
07 50 39
The DateRun Node value is now a header and the Count for each number is a value under each DateRun. (Number would go to 80 and stop. There are no numbers higher than 80)
Thank you for any help you might be able to provide!