【发布时间】:2020-08-31 17:05:26
【问题描述】:
考虑下面的表格,其中一列有 10 条记录。 我无法理解如何
SUM(1) gives output 10
SUM(2) gives output 20
SUM(3) gives output 30
create table test_a4(idCol numeric);
insert into test_a4(idCol) values (1),(2), (3), (4), (5) , (6), (7), (8), (9) , (10)
Select SUM(1) FROM test_a4 -- SUM(1) gives output 10
Select SUM(2) FROM test_a4 -- SUM(2) gives output 20
Select SUM(3) FROM test_a4 -- SUM(3) gives output 30
【问题讨论】:
-
您正在对文字数字求和,每行一次。因此,将总和中的数字乘以 10。即 sum(3) = 3 * 10。你希望它做什么?
标签: sql sql-server tsql sum aggregate-functions