query-7106c302f83d5e830b7d82aa10cc44b1
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT ?item ?property ?value ?unit ?qualifier ?qualifier_value ?qualifier_unit
WHERE
{
VALUES ?item { wd:Q658 }
VALUES ?property { wd:P2054 }
?property wikibase:claim ?claim .
# Get amount and unit for the statement
?item ?claim ?statement .
{
?property wikibase:propertyType ?property_type .
FILTER (?property_type != wikibase:Quantity)
?property wikibase:statementProperty ?propertyStatement .
?statement ?propertyStatement ?value .
}
UNION
{
?property wikibase:statementValue ?statementValue .
?statement ?statementValue [wikibase:quantityAmount ?value; wikibase:quantityUnit ?unit] .
}
# Get qualifiers
OPTIONAL
{
{
# Get simple values for qualifiers which are not of type quantity
?statement ?pq ?qualifier_value .
?qualifier wikibase:qualifier ?pq .
?qualifier wikibase:propertyType ?qualifer_property_type .
FILTER (?qualifer_property_type != wikibase:Quantity)
}
UNION
{
# Get amount and unit for qualifiers of type quantity
?statement ?pqv [wikibase:quantityAmount ?qualifier_value; wikibase:quantityUnit ?qualifier_unit] .
?qualifier wikibase:qualifierValue ?pqv .
}
}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?claim")
v1("?item"):::projected
v11("?pq")
v15("?pqv")
v2("?property"):::projected
v6("?propertyStatement")
v5("?property_type")
v10("?qualifer_property_type")
v13("?qualifier"):::projected
v14("?qualifier_unit"):::projected
v12("?qualifier_value"):::projected
v4("?statement")
v8("?statementValue")
v9("?unit"):::projected
v7("?value"):::projected
a1((" "))
a2((" "))
bind0[/VALUES ?item/]
bind0-->v1
bind00(["wd:Q658"])
bind00 --> bind0
bind1[/VALUES ?property/]
bind1-->v2
bind10(["wd:P2054"])
bind10 --> bind1
v2 --"wikibase:claim"--> v3
v1 -->v3--> v4
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v2 --"wikibase:statementValue"--> v8
a1 --"wikibase:quantityAmount"--> v7
a1 --"wikibase:quantityUnit"--> v9
v4 -->v8--> a1
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
f2[["?property_type != 'wikibase:Quantity'"]]
f2 --> v5
v2 --"wikibase:propertyType"--> v5
v2 --"wikibase:statementProperty"--> v6
v4 -->v6--> v7
end
union0r <== or ==> union0l
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
a2 -."wikibase:quantityAmount".-> v12
a2 --"wikibase:quantityUnit"--> v14
v4 -->v15--> a2
v13 --"wikibase:qualifierValue"--> v15
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
f3[["?qualifer_property_type != 'wikibase:Quantity'"]]
f3 --> v10
v4 -->v11--> v12
v13 --"wikibase:qualifier"--> v11
v13 --"wikibase:propertyType"--> v10
end
union1r <== or ==> union1l
end
end