最も簡単な方法は、おそらくunion all
:
select id, sum(value), min(data)
from t
where id is not null
group by id
union all
select id, value, data
from t
where id is null;
最も簡単な方法は、おそらくunion all
:
select id, sum(value), min(data)
from t
where id is not null
group by id
union all
select id, value, data
from t
where id is null;