Hi Yari. Thanks for your input, it is definitely a great use of SQL and more learning; however, the question say all processing needs to be done in Perl and that complex SQL and subqueries are not allowed. I think we need to get @returndata and go through it with loops in Perl.