mysql如何用作子查询
示例数据
日期 | 番茄 | 电话 | 书 | 笔笔 |
---|---|---|---|---|
2022-05-15 | 2 | 2 | 3 | 1 |
2022-05-15 | 3 | 3 3 | 3 | 2 |
我想见
date | tomato tomato | 电话 | 书 | 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';
GROUP BY date
delete from sales.copy
where date = '2022-05-15' and tomato < ( select max(tomato) from sales.copy where date = '2022-05-15' );
不起作用part
delete from sales.copy
where date = '2022-05-15' and tomato < ( select max(tomato) from sales.copy where date = '2022-05-15' );
example data
date | tomato | phone | book | pen |
---|---|---|---|---|
2022-05-15 | 2 | 2 | 3 | 1 |
2022-05-15 | 3 | 3 | 3 | 2 |
i want see
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';
GROUP BY date
delete from sales.copy
where date = '2022-05-15' and tomato < ( select max(tomato) from sales.copy where date = '2022-05-15' );
doesn't works part
delete from sales.copy
where date = '2022-05-15' and tomato < ( select max(tomato) from sales.copy where date = '2022-05-15' );
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了路!谢谢大家!
如果您找到了另一种方法
请尝试帖子
i found way! thanks everybody!
if you find another way
please, try post