SELECT "licprocesses_task"."task_type_id" FROM "licprocesses_task" LEFT OUTER JOIN "licprocesses_taskresult" ON ("licprocesses_task"."result_id" = "licprocesses_taskresult"."id") WHERE ("licprocesses_task"."process" IN (SELECT U0."document_id" FROM "licprocesses_process" U0 INNER JOIN "licprocesses_processtype" U1 ON (U0."process_type_id" = U1."id") LEFT OUTER JOIN "licenses_licensekind" U2 ON (U1."license_kind_id" = U2."id") WHERE ((U1."license_kind_id" IN (SELECT DISTINCT U0."id" FROM "licenses_licensekind" U0 WHERE U0."id" IN (12, 12, 11, 10, 10, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 10, 12, 12)) OR U1."license_kind_id" IS NULL) AND U0."document_end" > '2017-07-25 14:35:55.400457' AND U0."document_start" <= '2017-07-25 14:35:55.400457' AND (U2."id" IN (SELECT DISTINCT U0."id" FROM "licenses_licensekind" U0 WHERE U0."id" IN (12, 12, 11, 10, 10, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 10, 12, 12)) OR U2."id" IS NULL))) AND ("licprocesses_task"."cancel" = false  OR "licprocesses_task"."cancel" IS NULL) AND "licprocesses_task"."document_end" > '2017-07-25 14:35:55.382893' AND "licprocesses_task"."document_start" <= '2017-07-25 14:35:55.382893'  AND "licprocesses_taskresult"."id" IS NULL)