in reply to compare current row with previous row

Just keep the previous row in another variable, and do the comparison you described..
use Data::Dumper; my $prev_data; while (my $data = $sth->fetchrow_arrayref()) { if( $prev_data && $data->[0] == $prev_data->[0] && $data->[1] == $prev_data->[1] && $data->[2] == $prev_data->[2] ){ print $data->[4]; }else{ print Dumper $data; } $prev_data = $data; }
Some issues, however:

Replies are listed 'Best First'.
Re^2: compare current row with previous row
by Anonymous Monk on Jan 16, 2006 at 15:06 UTC
    First off.. apologies for not stating the issue more clearly. This was my first post so in future I'll try and be more specific.
    The select statement I put in was purely as an example to demonstrate the issue. Granted I should have selected multiple columns. The real statement I'm dealing with is about a page of A4 and contains some pretty horrendous sql (imo). Anyhow suffice it to say the select being issued is fixed.
    The number of columns actually being selected is 15 but I'm only interested in a comparison of some of these columns.
    Thanks for the answer by the way