Jump to content

Recommended Posts

Posted

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

Posted
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();

}

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.