How to total the number of records per Category using a VIEW SQL SERVER

1

Good evening. I'm not finding a way to, using or just calling a VIEW, count how many teachers there are in a given category, whose output should be the category and the quantity.

The VIEW I made is as follows:

CREATE VIEW VMostraProfessor AS
SELECT pro_nome AS Nome, cat_nome AS Categoria, tit_nome AS Titulação, 
CONVERT(VARCHAR(10), pro_nascimento, 103) AS Nascimento, cid_nome AS Cidade, pro_sexo AS Sexo FROM Professor p
    inner join categoria c ON c.cat_id = p.cat_id
    inner join titulacao t ON t.tit_id = p.tit_id
    inner join cidade cd ON cd.cid_ID = p.cid_id;

Can you do this in the call or inside the view? (Preferably on call)

Thanks for the help!

    
asked by anonymous 01.04.2018 / 02:51

1 answer

1
SELECT cmp.categoria,
       COUNT(1) AS quantidade
  FROM VMostraProfessor cmp
 GROUP BY cmp.categoria
    
01.04.2018 / 07:40