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:predicate "_fight_n_1"^^xsd:string } UNION { ?100 eds:predicate "_fight_v_1"^^xsd:string } } . { ?100 eds:arg2 ?y } UNION { ?100 eds:arg1 ?y } 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)))