I am facing an issue with data manipulation with sql query. I am having data as below and I need the output as shown below output.Any help would be of great helkp to me.
ITEM_ID PUR_BY AMOUNT CUST_ID DISCOUNT
1 AB 100 121 5
2 CD 200 121 4
3 EF 120 122 4
4 GH 130 122 3
5 IJ 140 123 4
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Thanks for the quick reply, but my problem is that in real world I would not know the value of pur_by and based on cust_id I have to combine pur_by column.In the example above, I may have 3..n pur_by value for the same cust_id and I need to calculate their sum based on this. Request for your help again.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Yes, you are right.. may be we can have another table inbetween with the mapping.In my case I am only concerned with cust_id, cant we group all the PUR_BY having the same cust_id. Otherwise I may have to introduced another mapping table.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Bookmarks