Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

MySQL transform pivot query

Posted on 2008-10-15
1
2,489 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Upgrade MySQL 5.5 to MySQL 5.6 on Windows 13 46
SubQuery link 4 35
mysql db 3 69
Giant ibd file for our biggest table on mysql 2 17
Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (http://www.sqlite.org/), A SQLite Tidbit: Quick Numbers Table Generation (http://www.experts-exchange.com/A_3570.htm…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

856 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