query-0ee8cc0fcf49e58ac4d2e041115491fe
Propertiesinstance of (P31)subclass of (P279)located in the administrative territorial entity (P131)phone number (P1329)has use (P366)field of work (P101)
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 pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?hospitalLabel ?phoneNumberLabel (GROUP_CONCAT(Distinct ?useLabel; separator= ", ") as ?usedFor)
(GROUP_CONCAT(Distinct ?fieldOfWorkLabel; separator= ", ") as ?field)
WHERE
{
?hospital wdt:P31/wdt:P279* wd:Q16917; #hospital
wdt:P131 wd:Q1711; #in administrative territory Potsdam
p:P1329 ?phoneNumberStatement.
?phoneNumberStatement pq:P366 ?use;
ps:P1329 ?phoneNumber.
?use rdfs:label ?useLabel.
#use rfs:label so it can be used with CONCAT aggregate function
FILTER(lang(?useLabel) = "en").
#if possible get the field of work
OPTIONAL{
?phoneNumberStatement pq:P101 ?fieldOfWork.
?fieldOfWork rdfs:label ?fieldOfWorkLabel.
FILTER(lang(?fieldOfWorkLabel) = "en").
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
GROUP BY ?hospitalLabel ?phoneNumberLabel
ORDER BY ?hospitalLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v10("?field")
v8("?fieldOfWork")
v3("?fieldOfWorkLabel"):::projected
v4("?hospital")
v1("?hospitalLabel"):::projected
v7("?phoneNumber")
v5("?phoneNumberStatement")
v6("?use")
v2("?useLabel"):::projected
v9("?usedFor")
a1((" "))
c6(["wd:Q1711"]):::iri
c1(["en"]):::literal
c13(["bd:serviceParam"]):::iri
c4(["wd:Q16917"]):::iri
f0[["?useLabel = 'en'"]]
f0 --> v2
v4 --"p:direct/P31"--> a1
a1 --"p:direct/P279"--> c4
v4 --"p:direct/P131"--> c6
v4 --"p:P1329"--> v5
v5 --"p:qualifier/P366"--> v6
v5 --"p:statement/P1329"--> v7
v6 --"rdfs:label"--> v2
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:qualifier/P101".-> v8
v8 --"rdfs:label"--> v3
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c13 --"wikibase:language"--> c1
end
bind3[/"?useLabel"/]
v2 --o bind3
bind3 --as--o v9
bind4[/"?fieldOfWorkLabel"/]
v3 --o bind4
bind4 --as--o v10