[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2495
  • Last Modified:

MySQL transform pivot query

This is my table...
INTERVENTION      |  Proj      | Proj2            | Proj 3|
200             |  2      | NULL       | NULL  |
200             |  NULL      | 3       | NULL  |
200             |  NULL      | NULL       | 4         |
203             |  5      | NULL       | NULL  |
203             |  NULL      | 9       | NULL  |
203             |  NULL      | NULL       | 2          |

What query do run to get this?

INTERVENTION      |Proj      | Proj2 |           Proj 3          |
200            |2      | 3      | 4      |
203            |5      | 9      | 2      |
0
hbojorquezgeek
Asked:
hbojorquezgeek
1 Solution
 
Tony McCreathTechnical SEO ConsultantCommented:
Looks like

select INTERVENTION, sum(Proj), sum(Proj2), sum(Proj3) from myTable  group by INTERVENTION;
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now