solution of http://sqlzoo.net