![](/img/trans.png)
[英]SQL COUNT(*) with GROUP BY and a final row with the total count
[英]SQL total row count
我需要選擇行數:
select
int_re_usu as Qtd_Respostas
from
tb_questionario_voar_resposta
group by
int_re_usu
它返回:
1- 687
2- 375076
3- 339012
4 -314083
5 -52741
6 -339977
7- 276041
8- 373304
9 - 339476
10- 51095
11- 270365
12 - 6
13 - 308670
14 -305232
15 - 85868
16 - 9893
17 -300598
18 - 300572
19 - 275889
20 - 6092
21 - 80092
22 - 307104
23 -273393
我想選擇數字23,即總row_count。
任何想法?
使用@@ RowCount
select int_re_usu as Qtd_Respostas from tb_questionario_voar_resposta group by int_re_usu
Select @@RowCount
或使用派生表
Select Count(*) from
(select int_re_usu as Qtd_Respostas from tb_questionario_voar_resposta group by int_re_usu) q1
使用COUNT() :
select COUNT(*) FROM (
SELECT int_re_usu as Qtd_Respostas
from tb_questionario_voar_resposta
group by int_re_usu
)
您可以使用DISTINCT而不是GROUP BY:
SELECT COUNT(DISTINCT int_re_usu)
FROM tb_questionario_voar_resposta
select count(*) from
( select int_re_usu as Qtd_Respostas from tb_questionario_voar_resposta group by int_re_usu ) as a
您可以使用count(*)函數。
select count(*)
from table_name
group by column_name
With temp as
( select int_re_usu as Qtd_Respostas
from tb_questionario_voar_resposta
group by int_re_usu )
Select count(*) from temp
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.