WebCodeGenie interview question

1. Logical question 2. SQL Query