That’s very interesting and very useful, (and I’ll have to keep that in my back pocket) but not exactly what I am looking for. Although, I don’t fully understand how the function works yet, so it just may be that the example that is in the blog post just isn’t the same as what I am looking for.
Here’s a better explanation.
Imagine you have part number 123. Part number 123 is located in 10 different bins, each with various quantities in them. I want to be able to do a query for the bin location that has the highest quantity in it. If I use the max function, I can find what the highest quantity is, but it won’t show me which bin number has the highest quantity. The reason that I need this in this case, it I want to be able to run a query to feed into DMT to do inventory transfers to move inventory from the highest quantity bin, into bins with most negative inventory. I need 1 bin for the max, and 1 bin for the max negative for the from and to bins. If I have double rows, this gets messed u, and the it will transfer twice.
If I use the rejoining method, I have a problem in that if the highest quantity is say, 10, but there are 2 bins with that quantity, I now have 2 rows. It’s also occurring to me as I am typing this, that no matter what function or technique I would use to get the bin number with the max, there has to be some sort of tie break function in order for any system to be able to get to one row.
For a single value/column, I can use the technique below, but many times you need more than one column returned, so that can be tedious, as you would have to set up a sub query for each column that I want returned. In this example, I need bin location and warehouse. Maybe it’s the best option we have though.