Simple query with GROUP BY question

Hello,

Imagine this simples query:

select 1 as A, 'test1' as B, '' as C
	
union
	
select 1 as A, '' as B, 'test2' as C

this returns :

---------------------
| A |   B   |   C   | 
---------------------
| 1 | test1 |       |
---------------------
| 2 |       | test2 |
---------------------

But I want to get:

---------------------
| A |   B   |   C   | 
---------------------
| 1 | test1 | test2 |
---------------------

I tried doing something like:

select t.A, t.B, t.C
from
(
	select 1 as A, 'test1' as B, '' as C
	
	union
	
	select 1 as A, '' as B, 'test2' as C
) as t
group by t.A, t.B, t.C

But that doesn’t work… How can I do this?

Thanks in advance!

SELECT t.A, [COLOR="Blue"]MAX(t.B)[/COLOR], [COLOR="blue"]MAX(t.C)[/COLOR]
  FROM ( SELECT 1 AS A, 'test1' AS B, '' AS C
         UNION ALL
         SELECT 1 AS A, '' AS B, 'test2' AS C
       ) AS t
GROUP 
    BY [COLOR="blue"]t.A[/COLOR]

Thanks :slight_smile: