query-8201a2daebf38af9947110c8e0eab8f6
As far as I know, STRBEFORE() and STRAFTER() are the only splitting functions in SPARQL accepting a string argument (SUBSTR() only accept a number). So here is a try: 09:34, 23 August 2020 (UTC) JuraIs there a way to differenciate them? --- : but I need to have them in distinct columns and not to use GROUP_CONCAT. Jura1Thank you @ 08:22, 23 August 2020 (UTC) JuraMaybe like the above .. I'm not sure how to split them into distinct variables. ---
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 pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT
?item ?itemLabel
?acronym_mb
(GROUP_CONCAT(DISTINCT str(?acronym); separator = ", ") as ?other_acronyms)
(GROUP_CONCAT(DISTINCT str(?acronym_old); separator = ", ") as ?old_acronyms)
WHERE
{
?item wdt:P1343 wd:Q96192978.
OPTIONAL { ?item p:P1813 ?st0 .
?st0 pq:P1535 wd:Q96192978 ; ps:P1813 ?acronym_mb .
FILTER NOT EXISTS { ?st0 pq:P582 [] }
}
OPTIONAL { ?item p:P1813 ?st1 . ?st1 ps:P1813 ?acronym .
FILTER NOT EXISTS { ?st1 pq:P1535 wd:Q96192978 }
FILTER NOT EXISTS { ?st1 pq:P582 [] }
}
OPTIONAL { ?item p:P1813 ?st2 . ?st2 ps:P1813 ?acronym_old .
FILTER EXISTS { ?st2 pq:P582 [] }
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,fr,de,it". }
}
GROUP BY ?item ?itemLabel ?acronym_mb
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?acronym"):::projected
v5("?acronym_mb"):::projected
v7("?acronym_old"):::projected
v4("?item"):::projected
v9("?old_acronyms")
v8("?other_acronyms")
v3("?st0")
v2("?st1")
v1("?st2")
a3((" "))
a2((" "))
a1((" "))
c10(["#91;AUTO_LANGUAGE#93;,en,fr,de,it"]):::literal
c3(["wd:Q96192978"]):::iri
c8(["bd:serviceParam"]):::iri
v4 --"p:direct/P1343"--> c3
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:P1813".-> v3
v3 --"p:qualifier/P1535"--> c3
v3 --"p:statement/P1813"--> v5
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:P1813".-> v2
v2 --"p:statement/P1813"--> v6
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:P1813".-> v1
v1 --"p:statement/P1813"--> v7
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c8 --"wikibase:language"--> c10
end
bind2[/"str(?acronym)"/]
v6 --o bind2
bind2 --as--o v8
bind3[/"str(?acronym_old)"/]
v7 --o bind3
bind3 --as--o v9