How to know the number of films by categories that have less than 50 films?

Asked

Viewed 169 times

-1

I have a movie chart with: -id_film, -movie name, -id_category; And another category with: id_category, category name;

how do I select only the category and amount of films of those that have less than 50 movies?

1 answer

-1


Try this (if you are using SQL Server):

SELECT NOME_CATEGORIA, COUNT(ID_FILME) AS QTD 
FROM TABELA1 (NOLOCK)
INNER JOIN TABELA2 (NOLOCK) ON
 TABELA1.ID_CATEGORIA = TABELA2.IDCATEGORIA
GROUP BY NOME_CATEGORIA
HAVING COUNT(ID_FILME) < 50

"HAVING" is also known as the "WHERE" of "GROUP BY".

Posting the code can help resolve your issue faster.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.