Lets say i have table called Orders
id qty1 qty2 qty3
-----------------------------------
1 1 2 3
2 0 1 0
3 3 2 1
Result of the query should be as following (Note qty are sum column wise for qty)
productID qty
----------------
1 4
2 5
3 4
Please help me to make query?
It looks like a very strange table design, and the results you want are even stranger. But this should do it:
If you would specify the type of SQL (PostgreSQL, MySQL, Oracle, etc…) server than I might be able to produce a neater query.