gpt4 book ai didi

mysql - SQL-如何从表中求和

转载 作者:行者123 更新时间:2023-11-29 04:18:21 25 4
gpt4 key购买 nike

我目前有以下数据:

  ID     state     
-------------------
1 display
2 display
3 display
4 display
5 no
6 yes

我知道如何对所有 ID 求和:

SELECT SUM(id)  FROM Message;

但是,我有最新的显示 ID (此处为 id = 4)

我正在尝试汇总消息的哪个状态不是display

已编辑:

我想对 ID 大于 4 的消息求和。

有什么建议吗?

最佳答案

试试这个:

SELECT SUM(id) FROM Message WHERE state !='display' and id > 4;

关于mysql - SQL-如何从表中求和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33580187/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com