Looking for alternatives to shorten sqlcode
P粉144705065
P粉144705065 2024-04-02 13:25:48
0
1
413

Please, I want to find another way

Sample data

date tomato Telephone Book Pen
2022-05-15 2 2 3 1
2022-05-15 3 3 3 2

I saw this result

date tomato Telephone 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 to explain this part briefly

'date, sum(tomato), sum(phone)...'

P粉144705065
P粉144705065

reply all(1)
P粉986028039

So just group the results

select date, 
       sum(tomato), 
       sum(phone),
       sum(book), 
       sum(pen) 
from copy 
where date = '2022-05-15' 
GROUP BY date
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template