Question: Give me all actors starring in movies directed by and starring William Shatner.
SPARQL:
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
PREFIX res: <http://dbpedia.org/resource/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?uri ?string WHERE 
{
        ?x dbo:director res:William_Shatner .
        ?x dbo:starring res:William_Shatner .
        { ?x dbo:starring ?uri . } UNION { ?x dbp:starring ?uri . }
        OPTIONAL { ?uri rdfs:label ?string. FILTER (lang(?string) = 'en') }
}