CGI Interview Question

also given an sql query