如何计算SQL行

时间:2012-09-06 22:33:21

标签: sql

SELECT count(*) FROM Stack WHERE Id = 33478 GROUP BY SID

Output:

(No column name)
1
4

结果;有两排。我该如何归还2? (行数)

有以下任何方式:

Select COUNT(SELECT count(*) FROM Stack WHERE ContentId = 33478 GROUP BY SID) ....

感谢。

1 个答案:

答案 0 :(得分:4)

您应该查看DISTINCT关键字:

SELECT COUNT(DISTINCT SID) FROM Stack WHERE Id = 33478