i have a hive table as below with 5 columns
name orderno productcategory amount description
KJFSFKS 1 1 40 D1
KJFSFKS 2 2 50 D2
KJFSFKS 3 2 67 D3
KJFSFKS 4 2 10 D4
KJFSFKS 5 3 2 D5
KJFSFKS 6 3 5 D6
KJFSFKS 7 3 6 D7
KJFSFKS 8 4 8 D8
KJFSFKS 9 5 8 D9
KJFSFKS 10 5 10 D10
desired output based on same product category code, if productcategory code is same across multiple rows add amount field, pick the description based on highest orderno, orderno always picklowest, output as below
name orderno productcategory amount description
KJFSFKS 1 1 40 D1
KJFSFKS 2 2 127 D4
KJFSFKS 5 3 13 D7
KJFSFKS 8 4 8 D8
KJFSFKS 9 5 18 D10
As said above,some fields are in some order, other in different order
i used group by but sum(amount) is fine, what about description field, it is based on orderno column, also there are other columns in my requirement where i should pick based on order number