---
# System prepended metadata

title: Untitled

---

#BACK END - AULA 7 E 8
```sql
//QUESTAO 1

select
	listed_in,count(show_id)
from
	netflix
group by
	listed_in
order by
	count (listed_in) desc
limit 5;

//QUESTAO 2

select 
	listed_in , avg (split_part(duration, ' ', 1):: int) as media
from
	netflix
where
	type = 'Movie'
group by listed_in
order by media desc
limit 5; 

//QUESTAO 3

select
	 release_year, listed_in, count( release_year)
from
	netflix
where
	type = 'TV Show'
group by release_year, listed_in
order by count(release_year) desc

limit 5;

// QUESTAO 5

select
	country, type, count(country ) 
from
	netflix
where
	type = 'TV Show' and not country = 'United States'
group by country, type
order by count(country)  desc
limit 5;

//QUESTAO 6

select
	listed_in, rating,count(description)
from
	netflix
where
	rating = 'R' or rating = 'NC-17'
group by listed_in, rating
order by count(description) desc
limit 5;
