MySQL Forums
Forum List  »  Newbie

Difficult.. How do you make a query to create columns that sums up rows based on condition?
Posted by: John Smith
Date: February 21, 2018 10:56AM

I am trying to solve this, I need a genius to help me please.

I have a table which contains quantity of products in different locations.

product location unit
produc1 locatioA 3000
produc3 locatioA 5000
produc2 locatioA 2000
produc1 locatioB 2000
produc3 locatioB 1000
produc1 locatioC 2000
produc2 locatioB 1000
produc2 locatioC 1000
produc3 locatioC 1500






Can somebody help me how can I produce custom column which will show like the following?


product loc_A loc_B loc_C Total
produc1 3000 2000 2000 7000
produc2 2000 1000 1000 4000
produc3 5000 1000 1500 7500




Many thanks in advance.

Options: ReplyQuote


Subject
Written By
Posted
Difficult.. How do you make a query to create columns that sums up rows based on condition?
February 21, 2018 10:56AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.