0
I’m having difficulties in an issue where my codes always go wrong.
The question is: Select the customer name and the number of phones they have registered classified in descending order by the number of phones.
My code:
SELECT DISTINCT clientes.nome ,COUNT(clientes_telefone.telefone) as telefones
from clientes
join clientes_telefone
ON clientes.codigo = clientes_telefone.cliente
Order BY telefone DESC;
I thought the code above would be right but, it shows:
Name | Telephone |
---|---|
Brigite | 5 |
I wanted all the names and the number of cell phones to appear, but when I put the count
, Everything gets crowded in Brigite.
I think Group By is missing from your query, and Distinct won’t be necessary
– imex