Hi Folks,
I need help with a simple query. I have a view called PARTS. It contains these columns:
PART_NO, BIN, QTY
What I want to do is return a list that shows the PART_NO and BIN that contains the greatest quantity.
Example:
123456 ABC 10
123456 XYZ 20
123456 DEF 30
123456 ZZZ 30
987654 AAA 10
In the example above I would like it to return:
123456 ZZZ
987654 AAA
1st reason: Because 30 is the greatest of the QTYs for part 123456
2nd reason: because 'ZZZ' is greater than 'DEF' (when the QTY is equal)
And of course return 987654 10 because it is the highest qty because there are no other rows for that part number.
I'm not very adept at SQL. Can anybody help me out?
-Striker
I need help with a simple query. I have a view called PARTS. It contains these columns:
PART_NO, BIN, QTY
What I want to do is return a list that shows the PART_NO and BIN that contains the greatest quantity.
Example:
123456 ABC 10
123456 XYZ 20
123456 DEF 30
123456 ZZZ 30
987654 AAA 10
In the example above I would like it to return:
123456 ZZZ
987654 AAA
1st reason: Because 30 is the greatest of the QTYs for part 123456
2nd reason: because 'ZZZ' is greater than 'DEF' (when the QTY is equal)
And of course return 987654 10 because it is the highest qty because there are no other rows for that part number.
I'm not very adept at SQL. Can anybody help me out?
-Striker