RRH Posted October 17, 2011 Report Share Posted October 17, 2011 (edited) Tenho o seguinte select:$sql = "SELECT placa, COUNT(*) AS total FROM veic GROUP BY placa ORDER BY total DESC, placa ASC";Ele agrupa por placa e dá o total.Ex:AAA-0000 = 5BBB-1111 = 1CCC-2222 = 6DDD-3333 = 1EEE-4444 = 10FFF-5555 = 12Agora a minha dúvida é se tem como filtrar de forma que só mostre "PLACA > 1" exibindo apenas as placas abaixo:AAA-0000 = 5CCC-2222 = 6EEE-4444 = 10FFF-5555 = 12 Edited October 18, 2011 by RRH Quote Link to comment Share on other sites More sharing options...
0 ESerra Posted October 17, 2011 Report Share Posted October 17, 2011 $sql = "SELECT placa, COUNT(*) AS total FROM veic GROUP BY placa HAVING total > 1 ORDER BY total DESC, placa ASC"; Quote Link to comment Share on other sites More sharing options...
0 RRH Posted October 18, 2011 Author Report Share Posted October 18, 2011 Impressionante! Exatamente o que eu precisava, muito obrigado. Quote Link to comment Share on other sites More sharing options...
Question
RRH
Tenho o seguinte select:
Ele agrupa por placa e dá o total.
Ex:
AAA-0000 = 5
BBB-1111 = 1
CCC-2222 = 6
DDD-3333 = 1
EEE-4444 = 10
FFF-5555 = 12
Agora a minha dúvida é se tem como filtrar de forma que só mostre "PLACA > 1" exibindo apenas as placas abaixo:
AAA-0000 = 5
CCC-2222 = 6
EEE-4444 = 10
FFF-5555 = 12
Edited by RRHLink to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.