query-f465e42abc6a7c14bc69decf11862965
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
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 ?IATA (max(?number) as ?passengers)
?year
where {
{
select ?item ?year (sum(?numberperperiod) as ?number) {
{
select ?item ?IATA ?statement ?year ?timevalue ?numberperperiod{
?item wdt:P31/wdt:P279* wd:Q644371.
?item wdt:P238 ?IATA.
?item p:P3872 ?statement.
?statement pqv:P585 ?timevalue
; ps:P3872 ?numberperperiod.
?timevalue wikibase:timeValue ?date .
optional { ?statement pq:P518 ?applies .}
filter(bound(?applies)=false || ?applies = wd:Q2165236 )
bind(if(bound(?applies)=false,"no applies","everywhere") as ?where )
MINUS { ?statement wikibase:rank wikibase:DeprecatedRank }
bind (YEAR(?date) AS ?year)
FILTER (?year >1949).
FILTER (?year < year(now())).
}
}.
?timevalue wikibase:timePrecision ?prec filter ( ?prec > 9 )
} group by ?item ?year
} union {
?timevalue wikibase:timePrecision 9 .
bind (?numberperperiod as ?number)
{
select ?item ?IATA ?statement ?year ?timevalue ?numberperperiod{
?item wdt:P31/wdt:P279* wd:Q644371.
?item wdt:P238 ?IATA.
?item p:P3872 ?statement.
?statement pqv:P585 ?timevalue
; ps:P3872 ?numberperperiod.
?timevalue wikibase:timeValue ?date .
optional { ?statement pq:P518 ?applies .}
filter(bound(?applies)=false || ?applies = wd:Q2165236 )
bind(if(bound(?applies)=false,"no applies","everywhere") as ?where )
MINUS { ?statement wikibase:rank wikibase:DeprecatedRank }
bind (YEAR(?date) AS ?year)
FILTER (?year >1949).
FILTER (?year < year(now())).
}
} } .
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }
} group by ?item ?itemLabel ?year ?IATA
order by ?item desc (?year)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?IATA"):::projected
v4("?applies")
v9("?date")
v1("?item"):::projected
v12("?number"):::projected
v8("?numberperperiod")
v12("?passengers")
v3("?prec")
v6("?statement")
v7("?timevalue")
v12("?where")
v12("?year"):::projected
a1((" "))
a2((" "))
c15(["wikibase:DeprecatedRank"]):::iri
c20(["fr"]):::literal
c7(["wd:Q644371"]):::iri
c18(["bd:serviceParam"]):::iri
c1(["9^^xsd:integer"]):::literal
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v7 --"wikibase:timePrecision"--> c1
bind0[/"?numberperperiod"/]
v8 --o bind0
bind0 --as--o v12
f1[["?year < year-from-dateTime(NOW())"]]
f1 --> v12
f2[["?year > '1949^^xsd:integer'"]]
f2 --> v12
f3[["(bound(?applies) = 'false^^xsd:boolean' || ?applies = 'wd:Q2165236')"]]
f3 --> v4
v1 --"p:direct/P31"--> a2
a2 --"p:direct/P279"--> c7
v1 --"p:direct/P238"--> v5
v1 --"p:P3872"--> v6
v6 --"p:qualifier/value/P585"--> v7
v6 --"p:statement/P3872"--> v8
v7 --"wikibase:timeValue"--> v9
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v6 -."p:qualifier/P518".-> v4
end
bind4[/"if(bound(?applies) = 'false^^xsd:boolean','no applies','everywhere')"/]
v4 --o bind4
bind4 --as--o v12
subgraph minus5["MINUS"]
style minus5 stroke-width:6px,fill:pink,stroke:red;
v6 --"wikibase:rank"--> c15
end
bind6[/"year-from-dateTime(?date)"/]
v9 --o bind6
bind6 --as--o v12
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
f7[["?prec > '9^^xsd:integer'"]]
f7 --> v3
f8[["?year < year-from-dateTime(NOW())"]]
f8 --> v12
f9[["?year > '1949^^xsd:integer'"]]
f9 --> v12
f10[["(bound(?applies) = 'false^^xsd:boolean' || ?applies = 'wd:Q2165236')"]]
f10 --> v4
v1 --"p:direct/P31"--> a1
a1 --"p:direct/P279"--> c7
v1 --"p:direct/P238"--> v5
v1 --"p:P3872"--> v6
v6 --"p:qualifier/value/P585"--> v7
v6 --"p:statement/P3872"--> v8
v7 --"wikibase:timeValue"--> v9
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v6 -."p:qualifier/P518".-> v4
end
bind11[/"if(bound(?applies) = 'false^^xsd:boolean','no applies','everywhere')"/]
v4 --o bind11
bind11 --as--o v12
subgraph minus12["MINUS"]
style minus12 stroke-width:6px,fill:pink,stroke:red;
v6 --"wikibase:rank"--> c15
end
bind13[/"year-from-dateTime(?date)"/]
v9 --o bind13
bind13 --as--o v12
v7 --"wikibase:timePrecision"--> v3
bind15[/"sum(?numberperperiod)"/]
v8 --o bind15
bind15 --as--o v12
end
union0r <== or ==> union0l
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c18 --"wikibase:language"--> c20
end
bind17[/"max(?number)"/]
v12 --o bind17
bind17 --as--o v12