Use of Concat() in Hive.

I have a table that is looks like:

PO_No Items Total_Qty Value PO_qty PO_value
777 10 100 5000 70 5000
777 10 -30 -2000 70 5000
777 20 200 7000 50 1000
777 20 -50 -3500 50 1000
777 30 80 2000 100 3000
777 30 40 1250 100 3000

Now I want to first concatenate PO_No and Items that is easy task and then check for each combination of concat(PO_No, Items), whether there is a negative value in the Total_Qty column. If yes, then sum up the Total_Qty values and compare with PO_qty. The result should be like:

PO_No Items Total_Qty Value PO_qty PO_value Comments


777 10 70 3000 70 5000 Total_Qty & PO_qty match and negative value in Total_Qty present
777 20 150 3500 50 1000 Total_Qty & PO_qty unmatched and negative value in Total_Qty present
777 30 120 3250 100 3000 Total_Qty & PO_qty unmatched and negative value in Total_Qty not present.
Can you please help in how to achieve this ?
Thanks in advance.

Tagged:
Sign In or Register to comment.