Re: SUM Top 10 records

2010-09-28 Thread Евгений Килимчук
I'm sorry! SELECT sum(rating) FROM (SELECT rating FROM your_table_name ORDER BY rating DESC LIMIT 5) AS result; 2010/9/28 Евгений Килимчук > select `rating`/100+`id` as result from `your_table_name` order by `rating` > desc LIMIT 5; > > ++ > | result | > ++ > | 4.5000 | > | 1.25

Re: SUM Top 10 records

2010-09-28 Thread Евгений Килимчук
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 > Hi > > I've a basic table like and want to SUM the top 5 values. For example if

Re: SUM Top 10 records

2010-09-28 Thread Tompkins Neil
Christoph, this SUMs all values ? On Tue, Sep 28, 2010 at 11:25 AM, Christoph Boget wrote: > > I've a basic table like and want to SUM the top 5 values. For example if > I > > have > > > > Any suggestions on how to achieve this ? > > > > SELECT SUM( rating ) as total_rating FROM my-table ORDER

SUM Top 10 records

2010-09-28 Thread Tompkins Neil
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