$UniqueDay = "SELECT count(*) as COUNT, max(time) as MAX, min(time) as MIN, attacksignature from np_data where month=? and day=? group by attacksignature as ATTACKSIG order by COUNT desc"; ##Unique Events $unique_events_sth = $db->prepare( $UniqueDay ); $unique_events_sth->execute($Month, $Day); while ( my $unique = $unique_events_sth->fetchrow_hashref ) { push( @unique_array, $unique ); }