How to count the number of records in a selection in a table

1

I made a selection of all the results of a table. What I need is to show the amount of these results. In my case, I need to show how many different specialties there are

SELECT "especialidade" FROM funcionarios GROUP BY "especialidade"

    
asked by anonymous 08.03.2018 / 22:13

2 answers

5

For "How many different specialties there are", Simple:

select 
    count(distinct especialidade) as qtd_especialidade
from funcionarios

or to "How many records per specialty:

select 
    especialidade,
    count(*) as qtd
from funcionarios group by especialidade
    
08.03.2018 / 22:15
2

@DiegoSoares You can use the following query:

1- Return total registrations select Specialty = count (distinct specialty) from officials

2- grouped by type of specialty select qtd = count (distinct specialty), specialty from officials Group by specialty

3-filtered by specialty select qtd = count (distinct specialty) Where specialty="filter to put" from officials

4- filtered and grouped select qtd = count (distinct specialty) Where specialty="filter 1 to put" from officials Union all select qtd = count (distinct specialty) Where specialty="filter 2 to place" from officials

5- various specialties select qtd = count (distinct specialty) Where specialty in ("filter to be placed", "filter 2") from officials

    
11.03.2018 / 00:04