为什么这个 sql 调用需要一个 where 子句?

Why does this sql call require a where clause?

我有一个 table 看起来像

ID         Name        amount
1          x             10
2          y             20
3          z             30

我想统计ID的个数,求和金额。 我试过了

SELECT COUNT(table.ID) as NumberOfIds and SUM(table.AMOUNT)
FROM table

但我不断收到错误消息,提示我缺少我的 where 语句。这两个函数本身都不需要 where 语句,那么为什么它们在一起时需要一个?

您不使用 and 指定多个所需结果,您使用逗号。

试试这个:

SELECT COUNT(table.ID) as NumberOfIds, SUM(table.AMOUNT) as SumOfAmounts
FROM table