query-e52f0bf18e7ba5b0faa01c35d8b38b87

rq turtle/ttl

All events from a special festival SELECT ?festival ?festivalLabel (GROUP_CONCAT(DISTINCT ?musicianLabel; separator=", ") AS ?musicians) ?nummer ?start ?end
WHERE { VALUES ?f { wd:Q3070337 } # Gnaoua World Music Festival (changy to whatever country you want) VALUES ?b { wdt:P740 wdt:P495 wdt:P27 } ?festival wdt:P31 ?f. OPTIONAL { ?festival p:P179 [ pq:P1545 ?nummer ] . } OPTIONAL { ?festival wdt:P580 ?start . } OPTIONAL { ?festival wdt:P582 ?end . } OPTIONAL { ?festival wdt:P710 ?musician . } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,fr". ?festival rdfs:label ?festivalLabel . ?musician rdfs:label ?musicianLabel . } } GROUP BY ?festival ?festivalLabel ?nummer ?start ?end ORDER BY ASC (?festivalLabel)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# All events from a special festival
SELECT ?festival ?festivalLabel 
      (GROUP_CONCAT(DISTINCT ?musicianLabel; separator=", ") AS ?musicians)
      ?nummer ?start ?end  
WHERE {
  VALUES ?f { wd:Q3070337 }  # Gnaoua World Music Festival (changy to whatever country you want)
  VALUES ?b { wdt:P740 wdt:P495 wdt:P27 }
  ?festival wdt:P31 ?f.
  OPTIONAL { ?festival p:P179 [ pq:P1545 ?nummer ] . }
  OPTIONAL { ?festival wdt:P580 ?start . }
  OPTIONAL { ?festival wdt:P582 ?end . }
  OPTIONAL { ?festival wdt:P710 ?musician . }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,fr". 
    ?festival rdfs:label ?festivalLabel .
    ?musician rdfs:label ?musicianLabel .
  }
}
GROUP BY ?festival ?festivalLabel ?nummer ?start ?end
ORDER BY ASC (?festivalLabel)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?b") v7("?end"):::projected v2("?f") v4("?festival"):::projected v1("?festivalLabel"):::projected v8("?musician") v9("?musicianLabel"):::projected v10("?musicians") v5("?nummer"):::projected v6("?start"):::projected a1((" ")) c8(["bd:serviceParam"]):::iri c10(["#91;AUTO_LANGUAGE#93;,en,fr"]):::literal bind0[/VALUES ?f/] bind0-->v2 bind00(["wd:Q3070337"]) bind00 --> bind0 bind1[/VALUES ?b/] bind1-->v3 bind10(["p:direct/P740"]) bind10 --> bind1 bind11(["p:direct/P495"]) bind11 --> bind1 bind12(["p:direct/P27"]) bind12 --> bind1 v4 --"p:direct/P31"--> v2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; a1 -."p:qualifier/P1545".-> v5 v4 --"p:P179"--> a1 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P580".-> v6 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P582".-> v7 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P710".-> v8 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 v4 --"rdfs:label"--> v1 v8 --"rdfs:label"--> v9 end bind3[/"?musicianLabel"/] v9 --o bind3 bind3 --as--o v10