query-0c0f12ea9b2867a63498a327259b5f47
">" not working (in a templated query)Hello, I discovered that in this query
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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
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 ?year ?item ?shortname (MAX(?number) AS ?passengers) (SAMPLE(COALESCE(?reference_URL, ?monthly_reference_URL2)) AS ?sample_reference_URL)
WHERE
{ { # Get the sum of monthly values within a year
SELECT ?item ?year (SUM(?max_numberperperiod) AS ?number) (SAMPLE(?monthly_reference_URL) AS ?monthly_reference_URL2)
WHERE
{ # Get the maximal value and a sample reference URL for each unique month
{ SELECT ?item ?year (MAX(?numberperperiod) AS ?max_numberperperiod) (SAMPLE(?reference_URL) AS ?monthly_reference_URL)
WHERE
{
{ SELECT ?item ?statement ?date ?year ?timevalue ?numberperperiod ?reference_URL
WHERE {
?item wdt:P238 ?airport_code
VALUES ?airport_code
{ "CDG" }
?item p:P3872 ?statement.
?statement pqv:P585 ?timevalue; ps:P3872 ?numberperperiod.
?timevalue wikibase:timeValue ?date.
OPTIONAL { ?statement pq:P518 ?applies. }
OPTIONAL { ?statement prov:wasDerivedFrom / (pr:P854|pr:P4656) ?reference_URL. }
FILTER (BOUND(?applies)=false || ?applies = wd:Q2165236)
MINUS { ?statement wikibase:rank wikibase:DeprecatedRank }
BIND (YEAR(?date) AS ?year)
}
} ?timevalue wikibase:timePrecision ?prec.
FILTER (?prec > 9)# precision more precise or equal to month
} GROUP BY ?item ?year ?date } } GROUP BY ?item ?year }
UNION
{
?timevalue wikibase:timePrecision 9.
BIND (?numberperperiod AS ?number)
BIND (?reference_URL AS ?sample_reference_URL)
{ SELECT ?item ?statement ?date ?year ?timevalue ?numberperperiod ?reference_URL
WHERE {
?item wdt:P238 ?airport_code
VALUES ?airport_code
{ "CDG" }
?item p:P3872 ?statement.
?statement pqv:P585 ?timevalue; ps:P3872 ?numberperperiod.
?timevalue wikibase:timeValue ?date.
OPTIONAL { ?statement pq:P518 ?applies. }
OPTIONAL { ?statement prov:wasDerivedFrom / (pr:P854|pr:P4656) ?reference_URL. }
FILTER (BOUND(?applies)=false || ?applies = wd:Q2165236)
MINUS { ?statement wikibase:rank wikibase:DeprecatedRank }
BIND (YEAR(?date) AS ?year)
}
} }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],fr,en". ?item rdfs:label ?itemLabel.}
BIND(COALESCE(?this,?itemLabel) as ?shortname)
} GROUP BY ?item ?shortname ?year ORDER BY ?item DESC (?year)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v16("?airport_code")
v4("?applies")
v9("?date")
v1("?item"):::projected
v16("?itemLabel")
v11("?max_numberperperiod")
v12("?monthly_reference_URL")
v14("?monthly_reference_URL2"):::projected
v15("?number"):::projected
v8("?numberperperiod")
v18("?passengers")
v3("?prec")
v10("?reference_URL"):::projected
v19("?sample_reference_URL")
v17("?shortname"):::projected
v6("?statement")
v7("?timevalue")
v16("?year"):::projected
a1((" "))
a2((" "))
c14(["wikibase:DeprecatedRank"]):::iri
c19(["#91;AUTO_LANGUAGE#93;,fr,en"]):::literal
c17(["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 v15
bind1[/"?reference_URL"/]
v10 --o bind1
bind1 --as--o v19
f2[["(bound(?applies) = 'false^^xsd:boolean' || ?applies = 'wd:Q2165236')"]]
f2 --> v4
v1 --"p:direct/P238"--> v16
bind3[/VALUES ?airport_code/]
bind3-->v16
bind30(["CDG"])
bind30 --> bind3
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
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v6 -."prov:wasDerivedFrom".-> a2
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
a2 --"p:reference/P4656"--> v10
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
a2 --"p:reference/P854"--> v10
end
union1r <== or ==> union1l
end
end
subgraph minus4["MINUS"]
style minus4 stroke-width:6px,fill:pink,stroke:red;
v6 --"wikibase:rank"--> c14
end
bind5[/"year-from-dateTime(?date)"/]
v9 --o bind5
bind5 --as--o v16
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
f6[["?prec > '9^^xsd:integer'"]]
f6 --> v3
f7[["(bound(?applies) = 'false^^xsd:boolean' || ?applies = 'wd:Q2165236')"]]
f7 --> v4
v1 --"p:direct/P238"--> v16
bind8[/VALUES ?airport_code/]
bind8-->v16
bind80(["CDG"])
bind80 --> bind8
v1 --"p:P3872"--> v6
v6 --"p:qualifier/value/P585"--> v7
v6 --"p:statement/P3872"--> v8
v7 --"wikibase:timeValue"--> v9
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v6 -."p:qualifier/P518".-> v4
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v6 -."prov:wasDerivedFrom".-> a1
subgraph union2[" Union "]
subgraph union2l[" "]
style union2l fill:#abf,stroke-dasharray: 3 3;
a1 --"p:reference/P4656"--> v10
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
a1 --"p:reference/P854"--> v10
end
union2r <== or ==> union2l
end
end
subgraph minus9["MINUS"]
style minus9 stroke-width:6px,fill:pink,stroke:red;
v6 --"wikibase:rank"--> c14
end
bind10[/"year-from-dateTime(?date)"/]
v9 --o bind10
bind10 --as--o v16
v7 --"wikibase:timePrecision"--> v3
bind13[/"max(?numberperperiod)"/]
v8 --o bind13
bind13 --as--o v11
bind14[/"sample(?reference_URL)"/]
v10 --o bind14
bind14 --as--o v12
bind17[/"sum(?max_numberperperiod)"/]
v11 --o bind17
bind17 --as--o v15
bind18[/"sample(?monthly_reference_URL)"/]
v12 --o bind18
bind18 --as--o v14
end
union0r <== or ==> union0l
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c17 --"wikibase:language"--> c19
v1 --"rdfs:label"--> v16
end
bind19[/"?this?itemLabel"/]
null --o bind19
v16 --o bind19
bind19 --as--o v17
bind22[/"max(?number)"/]
v15 --o bind22
bind22 --as--o v18
bind23[/"sample(?reference_URL?monthly_reference_URL2)"/]
v10 --o bind23
v14 --o bind23
bind23 --as--o v19