query-dc3c8dd7f7fda320d80ed831744cd78a

rq turtle/ttl

TODO

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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX pqv: <http://www.wikidata.org/prop/qualifier/value/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?IMO_number ?event ?eventLabel ?eventdate ?monthitemLabel WHERE {
  ?item wdt:P8047 wd:Q20.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "nb". }
  OPTIONAL { ?item p:P793 ?stat .
             ?stat ps:P793 ?event. 
             OPTIONAL {?stat pqv:P585 [
                wikibase:timePrecision ?precision ;
                wikibase:timeValue ?date_ ].
                BIND(IF(strlen(str(month(?date_)))=2,str(month(?date_)),concat("0",str(month(?date_)))) as ?month) 
                BIND(IF(strlen(str(day(?date_)))=2,str(day(?date_)),concat("0",str(day(?date_)))) as ?day) 
                BIND(IF(?precision=9,year(?date_),
                       IF(?precision=10,concat(str(year(?date_)),":",?month),
                         IF(?precision=11,concat(str(year(?date_)),":",?month,":",?day),""))) as ?date) 

                BIND(month(?date_) as ?monthdate)
                ?monthitem p:P279 ?statm . 
                ?statm ps:P279 wd:Q18602249.
                ?statm pq:P1545 ?monthdate2.
                FILTER(str(?monthdate2)=str(?monthdate))             
             }
             ?event rdfs:label ?eventLabel . filter(lang(?eventLabel)="nb")
             BIND(CONCAT(?eventLabel," ",str(?date)) as ?eventdate) 

            FILTER(?event IN (wd:Q906512, wd:Q1786766, wd:Q336332))
           }
  OPTIONAL { ?item wdt:P458 ?IMO_number. }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v15("?IMO_number"):::projected v11("?date") v8("?date_") v10("?day") v2("?event"):::projected v1("?eventLabel"):::projected v14("?eventdate"):::projected v3("?item"):::projected v9("?month") v12("?monthdate") v4("?monthdate2") v12("?monthitem") v7("?precision") v6("?stat") v13("?statm") a1((" ")) c18(["wd:Q18602249"]):::iri c6(["wd:Q20"]):::iri c8(["bd:serviceParam"]):::iri c1(["nb"]):::literal v3 --"p:direct/P8047"--> c6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c1 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:P793".-> v6 v6 --"p:statement/P793"--> v2 v2 --"rdfs:label"--> v1 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; a1 -."wikibase:timePrecision".-> v7 a1 --"wikibase:timeValue"--> v8 v6 --"p:qualifier/value/P585"--> a1 bind0[/"if(string-length(str(month-from-dateTime(?date_))) = '2^^xsd:integer',str(month-from-dateTime(?date_)),concat('0',str(month-from-dateTime(?date_))))"/] v8 --o bind0 bind0 --as--o v9 bind1[/"if(string-length(str(day-from-dateTime(?date_))) = '2^^xsd:integer',str(day-from-dateTime(?date_)),concat('0',str(day-from-dateTime(?date_))))"/] v8 --o bind1 bind1 --as--o v10 bind2[/"if(?precision = '9^^xsd:integer',year-from-dateTime(?date_),if(?precision = '10^^xsd:integer',concat(str(year-from-dateTime(?date_)),':',?month),if(?precision = '11^^xsd:integer',concat(str(year-from-dateTime(?date_)),':',?month,':',?day),'')))"/] v7 --o bind2 v8 --o bind2 v9 --o bind2 v10 --o bind2 bind2 --as--o v11 bind3[/"month-from-dateTime(?date_)"/] v8 --o bind3 bind3 --as--o v12 v12 --"p:P279"--> v13 v13 --"p:statement/P279"--> c18 v13 --"p:qualifier/P1545"--> v4 end bind4[/"concat(?eventLabel,' ',str(?date))"/] v1 --o bind4 v11 --o bind4 bind4 --as--o v14 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P458".-> v15 end