# Exercícios de Back-end 18/07/2020
## 1 - Questão
```sql
select
cervejas.name as nome_cerveja,
cervejas.style as estilo,
cervejarias.name as nome_cervejaria,
ibu,
abv
from
cervejas
inner join cervejarias
on cervejarias.id = cervejas.brewery_id
where
state = 'TX'
and ibu > 60
and style != 'American IPA'
and style != 'American Double / Imperial IPA';
```
## 2 - Questão
```sql
select
style as estilo,
count(*) as quantidade
from
cervejas
group by estilo
order by quantidade desc;
```
## 3 - Questão
```sql
select
cervejarias.state as estado,
count(cervejas.id) as total
from
cervejarias
inner join cervejas
on cervejarias.id = cervejas.brewery_id
where
cervejas.abv < 0.05
and cervejas.ibu > 15
group by estado
order by total desc
limit 1
offset 5;
```
## 4 - Questão
```sql
--- CERVEJAS MAIOR AMAGOR ---
select
cervejarias.name
from
cervejarias
inner join cervejas
on cervejarias.id = cervejas.brewery_id
where
cervejas.ibu > 40
group by cervejarias.name
order by count(cervejas.name) desc
limit 5;
--- CERVEJAS COM MAIOR TEOR ALCOÓLICO ---
select
cervejarias.name
from
cervejarias
inner join cervejas
on cervejarias.id = cervejas.brewery_id
where
cervejas.abv > 0.070
group by cervejarias.name
order by count(cervejas.name) desc
limit 5;
```
## 5 - Questão
```sql
select
cervejarias.state as estado
from
cervejarias
inner join cervejas
on cervejarias.id = cervejas.brewery_id
where
cervejas.abv > 0.070
and cervejas.ibu < 40
group by estado
order by count(cervejarias.state) desc
limit 1;
```
## 6 - Questão
```sql
select
cervejarias.state as estado,
cervejarias.city as cidade
from
cervejarias
inner join cervejas
on cervejarias.id = cervejas.brewery_id
where
cervejas.abv < 0.070
and cervejas.ibu > 40
group by estado, cidade
order by count(cervejarias.city) desc
limit 1;
```