Solved

MySQL transform pivot query

Posted on 2008-10-15
1
2,490 Views
Last Modified: 2012-05-05
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
Comment
Question by:hbojorquezgeek
1 Comment
 
LVL 23

Accepted Solution

by:
Tony McCreath earned 500 total points
ID: 22729999
Looks like

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

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question