Hi,
I have below table data vendor and vendorAmt
vendorID-----VendorType
1234---------ABCD
8907--------XYZ
4567--------PQRS
6785--------Undefined
3490--------FRST
7304--------Undefine
VendorID------Month-----Amount
1234---------Jan21------1000
8907---------Jan21------2000
4567---------Jan21------1500
1234---------FEB21------3000
3490---------FEB21------1000
6785---------FEB21------4000
6785---------Mar21------1000
7304---------Mar21------2000
4567---------Apr21------1500
6785---------Apr21------4000
8907---------Apr21------3000
Need to find the vendor type based on highest Amount
Condition - get the highest Vendor type based on amount but if highest vendor type is undefined then get the second highest vendor type (month FEB data). If all vendor type is undefined then undefined (Mar data), if highest is Undefined then pick the second value (Apr data)
Jan - Vendor type (XYZ/PQRS/ABCD) --- correct value is XYZ
FEB - Vendor type (Undefined/ABCD/FRST) -- correct value is ABCD
Mar - Vendor type (Undefined/Undefined) - - correct value is Undefined
Apr - vendor Type (Undefined/XYZ/PQRS) --- correct value is XYZ
Month-------VendorID-----Vendor Type
Jan21-------8907---------XYZ
FEB21-------1234---------ABCD
Mar21-------7304---------Undefined
Apr21-------8907---------XYZ
Any suggestion will be helpful
thanks in advance