query-1ee5be3c30f29dbf7cde87e5e8e5d523
title:breakdown of P5135/P5136 statements based on its qualifier value of P1013 SELECT ?aspect ?aspectLabel ?count ?statement WHERE { { SELECT (COUNT(?item) AS ?count) (SAMPLE(?st) AS ?statement) ?aspect WHERE { { ?item p:P5135 ?st. ?st ps:P5135 ?value. OPTIONAL { ?st pq:P1013 ?aspect. } } UNION { ?item p:P5136 ?st. ?st ps:P5136 ?value. OPTIONAL { ?st pq:P1013 ?aspect. } } } GROUP BY ?aspect } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } ORDER BY DESC(?count) ASC(?aspect)
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#title:breakdown of P5135/P5136 statements based on its qualifier value of P1013
SELECT ?aspect ?aspectLabel ?count ?statement WHERE {
{
SELECT (COUNT(?item) AS ?count) (SAMPLE(?st) AS ?statement) ?aspect WHERE {
{
?item p:P5135 ?st.
?st ps:P5135 ?value.
OPTIONAL { ?st pq:P1013 ?aspect. }
} UNION {
?item p:P5136 ?st.
?st ps:P5136 ?value.
OPTIONAL { ?st pq:P1013 ?aspect. }
}
}
GROUP BY ?aspect
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?count) ASC(?aspect)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?aspect"):::projected
v6("?count"):::projected
v3("?item")
v4("?st")
v6("?statement"):::projected
v5("?value")
c7(["bd:serviceParam"]):::iri
c9(["#91;AUTO_LANGUAGE#93;,en"]):::literal
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v3 --"p:P5136"--> v4
v4 --"p:statement/P5136"--> v5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:qualifier/P1013".-> v2
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v3 --"p:P5135"--> v4
v4 --"p:statement/P5135"--> v5
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:qualifier/P1013".-> v2
end
end
union0r <== or ==> union0l
end
bind2[/"count(?item)"/]
v3 --o bind2
bind2 --as--o v6
bind3[/"sample(?st)"/]
v4 --o bind3
bind3 --as--o v6
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end