ThiagoN Posted July 6, 2018 at 07:23 AM Report #611232 Posted July 6, 2018 at 07:23 AM 8m bom dia estou com dificuldade para criar um contador de registros duplicados no banco mysql preciso da informação qual a frequência que o nome aparece na lista, mas ele não mostra o resumo. ele aparece assim. Nome: RODRIGO AUGUSTO ALVES Frequência: 234 Nome: RODRIGO AUGUSTO ALVES Frequência: 117 Nome: RODRIGO AUGUSTO ALVES Frequência: 58 Nome: RODRIGO AUGUSTO ALVES Frequência: 29 Nome: RODRIGO AUGUSTO ALVES Frequência: 15 Nome: RODRIGO AUGUSTO ALVES Frequência: 7 Nome: RODRIGO AUGUSTO ALVES Frequência: 4 Nome: RODRIGO AUGUSTO ALVES Frequência: 2 Nome: RODRIGO AUGUSTO ALVES Frequência: 1 preciso que ele informe a soma da frequência. exemplo. Nome: RODRIGO AUGUSTO ALVES Frequência: 460 .segue codigo. List cont = Pln0048rJpaDAO.getInstance().findByCodigo(codigoTxt.getText()); while (cont.size() != 0){ int count = 0; String nome = “”; for (int i = 0; i < cont.size(); i ++){ nome = cont.get(i).getNome(); if(nome.equals(cont.get(i).getNome())){ count++; cont.remove(i); } else { i++; } } obrigado
ric.almeida Posted July 6, 2018 at 08:08 AM Report #611234 Posted July 6, 2018 at 08:08 AM Podes fazer na pesquisa a BD o SUM, e assim o resultado já te dava a soma da frequência.
ThiagoN Posted July 6, 2018 at 09:18 AM Author Report #611237 Posted July 6, 2018 at 09:18 AM Sou iniciante no Java. Tem algum exemplo para me ajudar.. obrigado
ric.almeida Posted July 6, 2018 at 11:29 AM Report #611239 Posted July 6, 2018 at 11:29 AM Podes mostrar como estas a fazer a pesquisa base de dados
ThiagoN Posted July 6, 2018 at 11:52 PM Author Report #611243 Posted July 6, 2018 at 11:52 PM 12 horas atrás, ric.almeida disse: Podes mostrar como estas a fazer a pesquisa base de dados acho que é assim... List cont = Pln0048rJpaDAO.getInstance().findByCodigo(codigoTxt.getText()); while (cont.size() != 0){ int count = 0; String nome = “”; for (int i = 0; i < cont.size(); i ++){ nome = cont.get(i).getNome(); }
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now