query-bd3c889607f1710670f1e8c195a01fb2
Why does the group_concat multiply up results for a few items?
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 p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?itemDescription ?location ?tripadvisor
(GROUP_CONCAT(DISTINCT ?propertyCategoryLabel; SEPARATOR = ", ") AS ?categories) WHERE {
{
SELECT ?item ?propertyCategoryLabel ?itemLabel ?itemDescription ?location ?tripadvisor WHERE {
{
?item p:P31 ?statement0.
?statement0 (ps:P31/(wdt:P279*)) wd:Q1785071.
}
UNION
{
?item p:P31 ?statement1.
?statement1 (ps:P31/(wdt:P279*)) wd:Q23413.
}
UNION
{
?item p:P31 ?statement2.
?statement2 (ps:P31/(wdt:P279*)) wd:Q56344492.
}
?item p:P7959 ?statement3.
?statement3 (ps:P7959/(wdt:P279*)) wd:Q67479626.
OPTIONAL { ?item wdt:P31 ?propertyCategory. }
OPTIONAL { ?item wdt:P3134 ?tripadvisor.}
OPTIONAL { ?item wdt:P625 ?location.}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
}
}
}
GROUP BY ?item ?itemLabel ?itemDescription ?location ?tripadvisor
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v10("?categories")
v1("?item"):::projected
v8("?location"):::projected
v6("?propertyCategory")
v9("?propertyCategoryLabel"):::projected
v2("?statement0")
v3("?statement1")
v4("?statement2")
v5("?statement3")
v7("?tripadvisor"):::projected
a1((" "))
a2((" "))
a3((" "))
a4((" "))
c9(["wd:Q67479626"]):::iri
c5(["wd:Q23413"]):::iri
c6(["wd:Q56344492"]):::iri
c4(["wd:Q1785071"]):::iri
c14(["bd:serviceParam"]):::iri
c16(["#91;AUTO_LANGUAGE#93;"]):::literal
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v1 --"p:P31"--> v4
v4 --"p:statement/P31"--> a3
a3 --"p:direct/P279"--> c6
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v1 --"p:P31"--> v3
v3 --"p:statement/P31"--> a2
a2 --"p:direct/P279"--> c5
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v1 --"p:P31"--> v2
v2 --"p:statement/P31"--> a1
a1 --"p:direct/P279"--> c4
end
union0r <== or ==> union0l
end
v1 --"p:P7959"--> v5
v5 --"p:statement/P7959"--> a4
a4 --"p:direct/P279"--> c9
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:direct/P31".-> v6
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:direct/P3134".-> v7
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:direct/P625".-> v8
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c14 --"wikibase:language"--> c16
end
bind1[/"?propertyCategoryLabel"/]
v9 --o bind1
bind1 --as--o v10