2
I have the following question. Consider that I have the following sales data:
Two former states: São Paulo (Atibaia, São Paulo and Campinas) and Paraná (Londrina, Curitiba, Cascavel).
| cidade | estado | vendas |
|-----------|--------|--------|
| Cascavel | PR | 10 |
| Curitiba | PR | 8 |
| Londrina | PR | 3 |
| Campinas | SP | 3 |
| São Paulo | SP | 5 |
| Atibaia | SP | 3 |
I need to bring the cities of their respective states that have the highest number of sales.
I made this command: to make a Count in the city brings the sum, but now I need to separate the cities. in this case would have to bring São Paulo and Cascavel.
select
count(d_clientes.cidade_nome), f_pedidos.cliente_sk, d_clientes.cliente_sk, d_clientes.cidade_nome, d_clientes.estado_nome, d_clientes.estado_sigla
from
f_pedidos
inner join d_clientes on f_pedidos.cliente_sk = d_clientes.cliente_sk
group by d_clientes.cidade_nome
lol n understood nothing the statement , edita ai rsss - type put your db structure and exactly as you want to order.
– Jasar Orion
I think you can use SQL MAX
– Sr. André Baill
@Jasarorion he understands well of SQL, top
– Sr. André Baill