please, i want find another way
example data
date | tomato | phone | book | pen |
---|---|---|---|---|
2022-05-15 | 2 | 2 | 3 | 1 |
2022-05-15 | 3 | 3 | 3 | 2 |
i see this result
date | tomato | phone | book | pen |
---|---|---|---|---|
2022-05-15 | 5 | 5 | 6 | 3 |
i use this
insert into sales.copy
select date,
sum(tomato),
sum(phone),
sum(book),
sum(pen)
from copy
where date = '2022-05-15';
delete from sales.copy
where date = '2022-05-15'
LIMIT 2;
but i want another way this part short
'date, sum(tomato), sum(phone)...'
So just group the result
select date,
sum(tomato),
sum(phone),
sum(book),
sum(pen)
from copy
where date = '2022-05-15'
GROUP BY date