I tried to post this yesterday in much more detail… but got an alert saying the post had to be approved? Not sure why, that’s never happened to me before, and it hasn’t been approved over 24 hours later… so let’s try this again!
Background: I’m building a base for employee clothing orders. Based an employee’s title, they get a certain allotment of clothing. If they want to get more than their allotted amount, they are responsible for paying for the overrun.
Let’s say a manager is allotted 5 sweatshirts. If the manager wants to get 7 sweatshirts, they are responsible for paying for the extra 2, and we will pay for the 5 most expensive items.
What makes this tricky, is that larger sizes have an associated upcharge. Say $2.50 for an XXL, $3.50 for a 3XL, and so on.
Table set up:
[Clothing Standards] holds each title and their associated allotments for each type of clothing.
[Items] holds all clothing items, sizes, and prices.
[Clothing Orders] links to [Clothing Standards] and [Items]. Here the items chosen are compared to the allowed allotments.
If I have all the sweatshirt prices in an array, can I sum just the 5 most expensive items? Or alternatively, the 2 least expensive items?