MySQL Forums :: General :: Counting occurences of data falling betwen a series of limits (buckets)


Advanced Search

Counting occurences of data falling betwen a series of limits (buckets)
Posted by: Peter Dzwig ()
Date: October 13, 2011 11:08AM

This ought to be trivial but...

I have a dataset in a MySQL DB which is about 30 rows wide and some 500+ rows deep - and this is a prototype of a much larger DB.

Think something like this:

Col_1 Col_2 Col_3 Col_4......
-----
500+ rows
-----

the data in (let's say) Col_2 is scattered between certain limits (say 1 to 9.5). What I want to do is create a number of buckets, let's say of width 0.01, and count up the number of values in Col_2 falling into each bucket.

The limits and the width of the buckets and hence the number of buckets need to be variable (other datasets have different ranges for Col_2)

The output should ideally be a table looking like:

BUCKET | NUMBER IN BUCKET

Bucket_1 | Count_1
Bucket_2 | Count_2
.
.
.
Bucket_last | Count_last

at this point no other data needs to appear in the new table.

FWIW the output data will be ultimately become a csv file for plotting.


It may just be getting late...

Thanks for any help that you can give,

Peter

Options: ReplyQuote


Subject Written By Posted
Counting occurences of data falling betwen a series of limits (buckets) Peter Dzwig 10/13/2011 11:08AM
Re: Counting occurences of data falling betwen a series of limits (buckets) Rick James 10/14/2011 05:22AM
Re: Counting occurences of data falling betwen a series of limits (buckets) Peter Dzwig 10/15/2011 10:22AM
Re: Counting occurences of data falling betwen a series of limits (buckets) Rick James 10/16/2011 09:27AM
Re: Counting occurences of data falling betwen a series of limits (buckets) Rick James 10/16/2011 08:53AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.