SELECT DISTINCT "File"."ClassName", "File"."LastEdited", "File"."Created", "File"."Name", "File"."Title", "File"."Filename", "File"."Content", "File"."ShowInSearch", "File"."Backuped", "File"."ParentID", "File"."OwnerID", "PropertyPhoto"."URLCloud", "PropertyPhoto"."UrlCloud2", "PropertyPhoto"."URLWM", "PropertyPhoto"."IsDefault", "PropertyPhoto"."Sort", "PropertyPhoto"."LastRequestWatermark", "PropertyPhoto"."proptjandraID", "PropertyPhoto"."PhotoID", "File"."ID", CASE WHEN "File"."ClassName" IS NOT NULL THEN "File"."ClassName" ELSE 'File' END AS "RecordClassName" FROM "File" LEFT JOIN "PropertyPhoto" ON "PropertyPhoto"."ID" = "File"."ID" WHERE ("PropertyPhoto"."proptjandraID" = ?) AND ("File"."ClassName" IN (?)) ORDER BY "IsDefault" DESC, "Sort" ASC, "File"."ID" ASC