query-3e050e0f07e36b3151d65d3462b479a4

rq turtle/ttl

tour management

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?tour ?tourLabel ?year ?tourClass ?tourClassLabel ?start ?end ?early ?late WHERE {
  ?tour wdt:P31 wd:Q47358534 .
  OPTIONAL { ?tour wdt:P585 ?pit . BIND(YEAR(?pit) AS ?year) }
  OPTIONAL {
    ?tour wdt:P3450 ?tourClass .
    OPTIONAL { ?tourClass wdt:P571 ?inception . BIND(YEAR(?inception) AS ?start) }
    OPTIONAL { ?tourClass wdt:P576 ?abolished . BIND(YEAR(?abolished) AS ?end) }
  }
  BIND(IF(BOUND(?year) && BOUND(?start) && ?year < ?start, 'too early', '') AS ?early) .
  BIND(IF(BOUND(?year) && BOUND(?end) && ?year > ?end, 'too late', '') AS ?late) .
  FILTER(?tourClass NOT IN (wd:Q50658948, wd:Q300029, wd:Q4535172, wd:Q300008, wd:Q299345, wd:Q41000, wd:Q127678, wd:Q3775082, wd:Q1991741, wd:Q671970, wd:Q4017355, wd:Q1193885, wd:Q299363)) . # complete tours
  FILTER(?tourClass NOT IN (wd:Q1563479, wd:Q128471, wd:Q50574730, wd:Q2701085, wd:Q1334786, wd:Q3789061, wd:Q50657938, wd:Q50658266, wd:Q6978903, wd:Q50658729, wd:Q4824513)) . # incomplete tours
  FILTER(?tourClass NOT IN (wd:Q2537906, wd:Q50549235, wd:Q7934510)) . # womens tours; complicated
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ASC(?tourClass) ASC(?year)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?abolished") v9("?early"):::projected v8("?end"):::projected v5("?inception") v10("?late"):::projected v4("?pit") v6("?start"):::projected v3("?tour"):::projected v1("?tourClass"):::projected v5("?year"):::projected c29(["wd:Q47358534"]):::iri c35(["bd:serviceParam"]):::iri c37(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["?tourClass != 'wd:Q2537906'?tourClass != 'wd:Q50549235'?tourClass != 'wd:Q7934510'"]] f0 --> v1 f1[["?tourClass != 'wd:Q1563479'?tourClass != 'wd:Q128471'?tourClass != 'wd:Q50574730'?tourClass != 'wd:Q2701085'?tourClass != 'wd:Q1334786'?tourClass != 'wd:Q3789061'?tourClass != 'wd:Q50657938'?tourClass != 'wd:Q50658266'?tourClass != 'wd:Q6978903'?tourClass != 'wd:Q50658729'?tourClass != 'wd:Q4824513'"]] f1 --> v1 f2[["?tourClass != 'wd:Q50658948'?tourClass != 'wd:Q300029'?tourClass != 'wd:Q4535172'?tourClass != 'wd:Q300008'?tourClass != 'wd:Q299345'?tourClass != 'wd:Q41000'?tourClass != 'wd:Q127678'?tourClass != 'wd:Q3775082'?tourClass != 'wd:Q1991741'?tourClass != 'wd:Q671970'?tourClass != 'wd:Q4017355'?tourClass != 'wd:Q1193885'?tourClass != 'wd:Q299363'"]] f2 --> v1 v3 --"wdt:P31"--> c29 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P585".-> v4 bind3[/"year-from-dateTime(?pit)"/] v4 --o bind3 bind3 --as--o v5 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P3450".-> v1 subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P571".-> v5 bind4[/"year-from-dateTime(?inception)"/] v5 --o bind4 bind4 --as--o v6 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P576".-> v7 bind5[/"year-from-dateTime(?abolished)"/] v7 --o bind5 bind5 --as--o v8 end end bind6[/"if(bound(?year)bound(?start)?year < ?start,'too early','')"/] v5 --o bind6 v6 --o bind6 bind6 --as--o v9 bind7[/"if(bound(?year)bound(?end)?year > ?end,'too late','')"/] v5 --o bind7 v8 --o bind7 bind7 --as--o v10 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c35 --"wikibase:language"--> c37 end