Reputation: 4133
I need to select the number of rows:
select
int_re_usu as Qtd_Respostas
from
tb_questionario_voar_resposta
group by
int_re_usu
It returns:
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
I want to select instead the number 23,which is the total row_count.
Any ideias?
Upvotes: 4
Views: 44678
Reputation: 404
With temp as
( select int_re_usu as Qtd_Respostas
from tb_questionario_voar_resposta
group by int_re_usu )
Select count(*) from temp
Upvotes: 1
Reputation: 11914
Instead of GROUP BY, you can use DISTINCT:
SELECT COUNT(DISTINCT int_re_usu)
FROM tb_questionario_voar_resposta
Upvotes: 3
Reputation: 86872
Use @@RowCount
select int_re_usu as Qtd_Respostas from tb_questionario_voar_resposta group by int_re_usu
Select @@RowCount
OR Use a Derived Table
Select Count(*) from
(select int_re_usu as Qtd_Respostas from tb_questionario_voar_resposta group by int_re_usu) q1
Upvotes: 9
Reputation: 12562
You can use the count(*) function.
select count(*)
from table_name
group by column_name
Upvotes: 1
Reputation: 13896
select count(*) from
( select int_re_usu as Qtd_Respostas from tb_questionario_voar_resposta group by int_re_usu ) as a
Upvotes: 1
Reputation: 7420
Use COUNT():
select COUNT(*) FROM (
SELECT int_re_usu as Qtd_Respostas
from tb_questionario_voar_resposta
group by int_re_usu
)
Upvotes: 6