SQL总行数

ozs*_*gal 4 sql

我需要选择行数:

select 
    int_re_usu as Qtd_Respostas 
from 
    tb_questionario_voar_resposta  
group by 
    int_re_usu
Run Code Online (Sandbox Code Playgroud)

它返回:

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
Run Code Online (Sandbox Code Playgroud)

我想选择数字23,即总row_count.

任何想法?

Joh*_*ock 8

使用@@ RowCount

select int_re_usu as Qtd_Respostas from tb_questionario_voar_resposta  group by int_re_usu
Select @@RowCount
Run Code Online (Sandbox Code Playgroud)

或使用派生表

Select Count(*) from 
(select int_re_usu as Qtd_Respostas from tb_questionario_voar_resposta  group by int_re_usu) q1
Run Code Online (Sandbox Code Playgroud)


tho*_*ulb 6

使用COUNT():

select COUNT(*) FROM (
    SELECT int_re_usu as Qtd_Respostas 
    from tb_questionario_voar_resposta
    group by int_re_usu
)
Run Code Online (Sandbox Code Playgroud)