I want to dynamically generate bands, that will then be grouped in reports.
My first thought was generate the bands by taking the minimum value and the maximum value and then dividing up the difference.
For instance suppose you had the salaries for a large group of people:
So then this isn't actually very useful. If I were to manually create the bands I'd want roughly similar numbers in each, something like: £12k-£14k, £14k-£18k, £18k-£25k, £25-£35k, ..., £1.5-£3million
This is just one example - there could be lots of different distributions.
I'm looking for an algorithm to generate the bands, so users would enter how many bands they want and the data would be grouped into that many bands with a similar number in each.
The banding needs to be quick - I can't just loop through the entire dataset.
The application is C# on top of SQL, but solutions from other languages welcome.
i think you are asking about how to query an existing dataset into the 'bands'...
if this is true, then Oracle supports NTILE aggregate functions fo rthis purpose. There should be equivalents in other SQL implementations.