InfoCepts Interview Question

Puzzle and sql query questions