Grouping
- Collect data into groups and process
Group all airports by state and count it. THE into stores a numerical value in the var total.
FOR airport in airports
COLLECT state = airport.state WITH COUNT INTO total
SORT total DESC
RETURN {state,total}
Now we can review the state with the most airpots.
[
{
"state": "AK",
"total": 263
},
{
"state": "TX",
"total": 209
},
{
"state": "CA",
"total": 205
},
{
"state": "OK",
"total": 102
},
{
"state": "FL",
"total": 100
},
{
"state": "OH",
"total": 100
},
{
"state": "NY",
"total": 97
},
{
"state": "GA",
"total": 96
},
{
"state": "MI",
"total": 94
},
{
"state": "MN",
"total": 89
},
{
"state": "IL",
"total": 88
},
{
"state": "WI",
"total": 84
},
{
"state": "KS",
"total": 78
},
{
"state": "IA",
"total": 78
},
{
"state": "MO",
"total": 74
},
{
"state": "AR",
"total": 74
},
{
"state": "AL",
"total": 73
},
{
"state": "NE",
"total": 73
},
{
"state": "MS",
"total": 72
},
{
"state": "NC",
"total": 72
},
{
"state": "PA",
"total": 71
},
{
"state": "MT",
"total": 71
},
{
"state": "TN",
"total": 70
},
{
"state": "IN",
"total": 65
},
{
"state": "WA",
"total": 65
},
{
"state": "AZ",
"total": 59
},
{
"state": "SD",
"total": 57
},
{
"state": "OR",
"total": 57
},
{
"state": "LA",
"total": 55
},
{
"state": "ND",
"total": 52
},
{
"state": "SC",
"total": 52
},
{
"state": "NM",
"total": 51
},
{
"state": "KY",
"total": 50
},
{
"state": "CO",
"total": 49
},
{
"state": "VA",
"total": 47
},
{
"state": "ID",
"total": 37
},
{
"state": "NJ",
"total": 35
},
{
"state": "UT",
"total": 35
},
{
"state": "ME",
"total": 34
},
{
"state": "WY",
"total": 32
},
{
"state": "NV",
"total": 32
},
{
"state": "MA",
"total": 30
},
{
"state": "WV",
"total": 24
},
{
"state": "MD",
"total": 18
},
{
"state": "HI",
"total": 16
},
{
"state": "CT",
"total": 15
},
{
"state": "NH",
"total": 14
},
{
"state": "VT",
"total": 13
},
{
"state": "NA",
"total": 12
},
{
"state": "PR",
"total": 11
},
{
"state": "RI",
"total": 6
},
{
"state": "DE",
"total": 5
},
{
"state": "VI",
"total": 5
},
{
"state": "CQ",
"total": 4
},
{
"state": "AS",
"total": 3
},
{
"state": "GU",
"total": 1
},
{
"state": "DC",
"total": 1
}
]