PREFIX rdfs: PREFIX xsd: PREFIX owl: PREFIX rdf: PREFIX eds: select ?graph (group_concat(?100; separator = "\t") AS ?100Values) (group_concat(?x; separator = "\t") AS ?xValues) (group_concat(?y; separator = "\t") AS ?yValues) where { GRAPH ?graph { { ?100 eds:arg4 ?y } UNION { { ?100 eds:arg ?y } UNION { { ?100 eds:arg3 ?y } UNION { { ?100 eds:arg2 ?y } UNION { ?100 eds:arg1 ?y } } } } ?100 eds:predicate ?100TEXT . FILTER regex(?100TEXT, "^_fi.*$") . FILTER ( ( !bound(?100) || !bound(?x) || ?100!=?x ) && ( !bound(?100) || !bound(?y) || ?100!=?y ) && ( !bound(?x) || !bound(?y) || ?x!=?y ) ) } } GROUP BY ?graph ORDER BY ASC(xsd:integer(STR(?graph)))