Reorganised query again. Added tests. Almost all is supported.

Subqueries work only in From clause. Have to add it to Select, Where and
Having.