Advanced SQL Update Query ?

peloffis_at_hotmail.com
Date: 10/27/04


Date: Wed, 27 Oct 2004 15:15:40 GMT

I would like to update a field in a table based on the summazition query of
a value in the same table where the value of the record is in the top 10% of
the total value

In my head I figure I need to get the the following :

                   "select sum(inventory.value) from inventory" = 2700
                    10% of the total = 270
                    Order the items by value
                    The first item, item_no 5 is > then 270 so it alone
makes up 10% of the value or greater.
                    Now i need to update item_no 5's ABC_code to 'A'

                    Eventually I need to look for the top 20% and make them
'B' except if it is already an 'A'. I figure I will update everything to an
'B' first then update for the 'A' items. (20% would
= 540, thus Item_no 3 would be a "B")

Thank you for any assistance.

sample table name inventory.
Item_No Value ABC_Code
1 100 C
2 200 C
3 490 C
4 100 C
5 510 C
6 400 C
7 200 C
8 300 C
9 100 C
10 300 C


Loading