想要关于 sqlcode 的另一种简码
Want another way shortcode about sqlcode
拜托,我想换个方式
示例数据
date
tomato
phone
book
pen
2022-05-15
2
2
3
1
2022-05-15
3
3
3
2
我看到了这个结果
date
tomato
phone
book
pen
2022-05-15
5
5
6
3
我用这个
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;
但我想用另一种方式缩短这部分
'date, sum(tomato), sum(phone)...'
所以只需对结果进行分组
select date,
sum(tomato),
sum(phone),
sum(book),
sum(pen)
from copy
where date = '2022-05-15'
GROUP BY date
拜托,我想换个方式
示例数据
date | tomato | phone | book | pen |
---|---|---|---|---|
2022-05-15 | 2 | 2 | 3 | 1 |
2022-05-15 | 3 | 3 | 3 | 2 |
我看到了这个结果
date | tomato | phone | book | pen |
---|---|---|---|---|
2022-05-15 | 5 | 5 | 6 | 3 |
我用这个
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;
但我想用另一种方式缩短这部分
'date, sum(tomato), sum(phone)...'
所以只需对结果进行分组
select date,
sum(tomato),
sum(phone),
sum(book),
sum(pen)
from copy
where date = '2022-05-15'
GROUP BY date