How to Do a Group By on a Single Property Using the Array Reduce Method

Group by, arrays, maps, reduce, and more

Photo by the author, Hydra island

The SQL GROUP BY statement allows to create of groups of related data and then apply aggregate functions like SUM, MIN, or MAX.

Consider the following LocationsReport table storing the number of the company locations per city.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store