InfoCepts interview question

Puzzle and sql query questions