Forum Moderators: coopster

Message Too Old, No Replies

group them to have the same average

         

Jiaxin

3:55 pm on Jul 9, 2011 (gmt 0)

10+ Year Member



Hi, I need help with this.

If I have a table, in the database containing fruits, price, quantity.

I want to arrange the price of the fruits into 3 groups of around the same average. Is it possible?

Thank you

rocknbil

4:32 pm on Jul 9, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You probably only need mysql, order by and avg().

select table.username, avg(score) as average from table group by table.title order by avg(score) asc;

May give you syntax errors but that's the direction to move in.

avg() [dev.mysql.com]

Jiaxin

4:38 pm on Jul 9, 2011 (gmt 0)

10+ Year Member



Yeah, i did have that. and i created array. im stuck after that =/

rocknbil

4:16 pm on Jul 11, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why did you need to create an array? That might be where it's getting mixed up. Does the data output raw from mysql in the correct order?