begin
query1.first;
edadant:=query1.fieldbyname('Edad').Value;
cuantos:=1;
cuantosmoda:=cuantos;
edadmoda:=query1.fieldbyname('Edad').Value;
query1.Next;
while Query1.Eof=False do
begin
showmessage('edadant trae '+Inttostr(edadant)+' y area actual es '+query1.fieldbyname('Edad').AsString);
if edadant=query1.fieldbyname('Edad').Value then
// showmessage('El dato NO cambio');
begin
cuantos:=cuantos+1;
// cuantosmoda:=cuantos;
showmessage('Cuantos moda trae '+IntToStr(cuantosmoda));
end
else
if cuantos > cuantosmoda then
begin
// showmessage('El dato cambio');
cuantosmoda:=cuantos;
edadmoda:=edadant;
showmessage('Cuantosmoda lleva '+ IntToStr(cuantosmoda));
showmessage('Edadmoda trae '+ IntToStr(edadmoda));
end;
if edadant<>query1.fieldbyname('Edad').Value then
cuantos:=1;
edadant:= query1.fieldbyname('Edad').Value;
query1.Next;
end;
if cuantos>cuantosmoda then
begin
cuantosmoda:=cuantos;
edadmoda:=edadant;
end;
end;
showmessage('Edad moda es '+ IntToStr(edadant)+' y se repite ' + IntToStr(cuantosmoda));