View Single Post

   
  #3 (permalink)  
Old 04-29-2008, 08:27 PM
Greg Hennessy
 
Posts: n/a
Default Re: how to get three lowest entries per bin

On 2008-04-27, Erick T Barkhuis <erick.use-net@ardane.c-o-m> wrote:
> Greg Hennessy:
>
>> What would ask for to get the largest three values
>> in each bin?

>
> select bin
> from data
> order by bin desc
> limit 3


That does seem to get me what I think it should.

mysql> select * from data;
+------+------+
| flux | bin |
+------+------+
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
| 2 | 2 |
| 4 | 2 |
| 6 | 2 |
| 8 | 2 |
| 4 | 1 |
+------+------+
8 rows in set (0.00 sec)

mysql> select flux,bin from data order by bin desc limit 3;
+------+------+
| flux | bin |
+------+------+
| 2 | 2 |
| 4 | 2 |
| 6 | 2 |
+------+------+
3 rows in set (0.00 sec)

While I get the three smallest flux in bin 2, I get no results
from bin one.



Reply With Quote