Parsing sql-query