Reputation: 3
I have data as below.
Group Jan Feb Mar
---|------|-----|-------|--------|---------
| A | I22 | | |
| A | | I22 | |
| A | | | I22 |
| B | I33 | | |
| B | | I33 | |
| B | | | I33 |
How is the query to make the data like this:-
Group Jan Feb Mar
---|------|-----|-------|--------|---------
| A | I22 | I22 | I22 |
| B | I33 | I33 | I33 |
Upvotes: 0
Views: 135
Reputation: 135739
Group is a keyword so you'll need to escape it appropriately for your RDBMS (e.g., square brackets for SQL Server, backticks for MySQL, etc).
SELECT [Group], MAX(Jan), MAX(Feb), MAX(Mar)
FROM YourTable
GROUP BY [Group]
Upvotes: 1