简体   繁体   中英

Want another way shortcode about sqlcode

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM