query-cc6e935a5607531d490c1c80b582c7b9
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?NGMDb_id ?DOI
WHERE
{
?item wdt:P6693 ?NGMDb_id .
optional { ?item wdt:P356 ?DOI . }
bind(strlen(?NGMDb_id) as ?len)
bind(if(?len=1,concat("00000",?NGMDb_id),
if(?len=2,concat("0000",?NGMDb_id),
if(?len=3,concat("000",?NGMDb_id),
if(?len=4,concat("00",?NGMDb_id),
if(?len=5,concat("0",?NGMDb_id),?NGMDb_id))))) as ?id2)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by ?id2
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?DOI"):::projected
v3("?NGMDb_id"):::projected
v6("?id2")
v2("?item"):::projected
v5("?len")
c4(["bd:serviceParam"]):::iri
c6(["#91;AUTO_LANGUAGE#93;,en"]):::literal
v2 --"wdt:P6693"--> v3
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P356".-> v4
end
bind0[/"string-length(?NGMDb_id)"/]
v3 --o bind0
bind0 --as--o v5
bind1[/"if(?len = '1^^xsd:integer',concat('00000',?NGMDb_id),if(?len = '2^^xsd:integer',concat('0000',?NGMDb_id),if(?len = '3^^xsd:integer',concat('000',?NGMDb_id),if(?len = '4^^xsd:integer',concat('00',?NGMDb_id),if(?len = '5^^xsd:integer',concat('0',?NGMDb_id),?NGMDb_id)))))"/]
v5 --o bind1
v3 --o bind1
bind1 --as--o v6
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c4 --"wikibase:language"--> c6
end