mysql如何用作子查询

发布于 2025-01-31 07:51:38 字数 1836 浏览 5 评论 0原文

示例数据

日期番茄电话笔笔
2022-05-152231
2022-05-1533 332

我想见

datetomato tomato电话2022-05
-155563

我使用此

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

datetomatophonebookpen
2022-05-152231
2022-05-153332

i want see

datetomatophonebookpen
2022-05-155563

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒解孤独 2025-02-07 07:51:38

我找到了路!谢谢大家!

delete from sales.copy WHERE date = '2022-05-15' AND tomato < ( select MAX(tomato) FROM (SELECT tomato from sales.copy where date = '2022-05-15') AS temp );

如果您找到了另一种方法
请尝试帖子

i found way! thanks everybody!

delete from sales.copy WHERE date = '2022-05-15' AND tomato < ( select MAX(tomato) FROM (SELECT tomato from sales.copy where date = '2022-05-15') AS temp );

if you find another way
please, try post

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文