0

Hi, I need help to go about doing 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. How do I do this?

Thank you

Edited by Jiaxin: n/a

4
Contributors
8
Replies
9
Views
6 Years
Discussion Span
Last Post by almostbob
0

Homework assignment?

You need to come up with the initial approach and then if you have specific questions or problems then you can post those and someone may be able to help you. If you haven't got a clue as to how to even start, then it's time to hit the books, use your brain or give up.

0

I only had sql which arrange them into asc order and have arrays. the rest im not sure. but its okay. thanks anyway

0
select count(*) as num from table
select * from table order by price limit 0, num/3
select * from table order by price limit num/3, num/3
select * from table order by price limit 2*num/3. num/3

not a mean price, set around 3 median price groups, you can do the math to create means from the price data

Edited by almostbob: n/a

0

Which mathematical / stat model are you using to group around a number?

Are you using ANOVA or similar?

//EDIT

disregard, I just reread the post

Edited by diafol: n/a

0
select count(*) as num from table
select * from table order by price limit 0, num/3
select * from table order by price limit num/3, num/3
select * from table order by price limit 2*num/3. num/3

not a mean price, set around 3 median price groups, you can do the math to create means from the price data

what does the limit does? and what do you mean by set around 3 median price groups? Actually what i was thinking was to group the price into asc, then the first with the last in one group, the second first and the second last into another group and so on. so i create the array,

$group1 = new arraylist(1,6,11,20,25);
$group2 = new arraylist(2,7,12,29,24);

note: my number of fruit is fixed.

i am stuck here after that. Not sure how to link them together.

0

note: my number of fruit is fixed.

what does this mean? only 10 entries?

Not sure how to link them together.

link what together?

Edited by diafol: n/a

0

only 25 entries. link the array with the actually price in database.

0

rephrase the question
3 groups where the price of the item is around the same average
or
3 groups where the average price of the group is the same

25 items, only, its as simple to add a freking column for the group number
Even for a homework assignment this is a strange one

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.