I need to sort my records by the largest number of GROUPS , that is, I have the SQL below and I need the TYPE column to be grouped >, be sorted from the largest grouping to the smallest, excluding display of TYPE that does not have GROUP .
(SELECT tipo, count(id) as quantidade
FROM imoveis
WHERE cod = '$cliente'
AND negociacao <> '0'
GROUP BY tipo)
ORDER BY quantidade DESC
I look forward to helping you.