select `rating`/100+`id` as result from `your_table_name` order by `rating`
desc LIMIT 5;

+--------+
| result |
+--------+
| 4.5000 |
| 1.2500 |
| 7.2000 |
| 6.1500 |
| 0.1000 |
+--------+

2010/9/28 Tompkins Neil <neil.tompk...@googlemail.com>

> Hi
>
> I've a basic table like and want to SUM the top 5 values.  For example if I
> have
>
> id, rating
> 0, 10
> 1, 25
> 2, 5
> 3, 10
> 4, 50
> 5, 1
> 6, 15
> 7, 20
> 8, 9
>
> I want my query to sum the values
>
> 4,50
> 1,25
> 7,20
> 6.15
> 0,10
>
> Suming a value of 120
>
> Any suggestions on how to achieve this ?
>
> Cheers
> Neil
>



-- 
Best regards,

Eugene Kilimchuk <ekilimc...@gmail.com>

Reply via email to