Your original coding attempt is repeatedly overwriting the $dataPoints variable inside of the loop -- this is why you only see the last iteration's data.
To create the desired multidimensional array directly from the query's result set, here is the way to use column aliases and Joomla's query building syntax.
$db = JFactory::getDbo();
$query = $db->...
If you implement the code from my earlier code, then you only need to write a dynamic $having array to generate the correct HAVING clause. I must note that your current coding attempt is not stable/secure. You are receiving user-supplied data from $_POST and feeding it directly into your raw sql. This means that there are no validating or sanitising steps ...
You have the instruction in your code, but commented.
The query setLimit() function requires two parameters:
$limit: the number of records to return, and
$offset: the first record you want to return, zero-based.
This is the signature of the function:
public function setLimit($limit = 0, $offset = 0)
Please take notice that the parameter order is opposite ...