# I'm not sure if it's the correct statement # for getting the data sorted newest first, test it first &DBEXEC("select proc_eventvu.job_name, jobst.status, proc_eventvu.stamp, proc_eventvu.text from proc_eventvu, jobst where proc_eventvu.joid = jobst.joid and proc_eventvu.event in (112,$eventnumber) and jobst.status = $statusnumber order by proc_eventvu.stamp desc"); my %already_processed; my @results_lol; while(@status = &dbnextrow($dbproc)) { $name = ($status[0]); $jstatus = &JOBSTATUS($status1); $estamp = ($status2); $etext = ($status3); # only the job data for a jobname # that wasn't processed before # make it to the result list unless (defined $already_processed{$name}) { push @results_lol, [($name, $jstatus, $estamp, $etext)]; $already_processed{$name} = 1; } } # here, if you want the rows sorted by name, you could # write some necessary code for my $row_ref (@results_lol) { my ($name, $jstatus, $estamp, $etext) = @$row_ref; write; }