Perl - PostGreSql query

Guys,

I guess, I posted something in the wrong forum. Here it is -

Can you please help me with this?

Regards,
garric