query-7ccb024b5d39a9c2211599cd8cb38624
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?p772 ?older ?olderLabel ?newer ?newerLabel {
VALUES ?p131 {wd:Q3908}
?item1 wdt:P772 ?p772; wdt:P131* ?p131a .
?item2 wdt:P772 ?p772; wdt:P131* ?p131b .
FILTER(?p131a=?p131 || ?p131b=?p131)
FILTER(STR(?item1)<STR(?item2)) .
BIND(xsd:integer(STRAFTER(STR(?item1),'/Q')) AS ?q1)
BIND(xsd:integer(STRAFTER(STR(?item2),'/Q')) AS ?q2)
BIND(IF(?q1<?q2,?item1,?item2) AS ?older)
BIND(IF(?q1<?q2,?item2,?item1) AS ?newer)
SERVICE wikibase:label { bd:serviceParam wikibase:language "es" } .
}
ORDER BY ?p772
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?item1")
v3("?item2")
v10("?newer"):::projected
v9("?older"):::projected
v7("?p131")
v4("?p131a")
v6("?p131b")
v1("?p772"):::projected
v7("?q1")
v8("?q2")
c4(["bd:serviceParam"]):::iri
c6(["es"]):::literal
f0[["str(?item1) < str(?item2)"]]
f0 --> v2
f0 --> v3
f1[["(?p131a = ?p131 || ?p131b = ?p131)"]]
f1 --> v4
f1 --> v7
f1 --> v6
bind2[/VALUES ?p131/]
bind2-->v7
bind20(["wd:Q3908"])
bind20 --> bind2
v2 --"wdt:P772"--> v1
v2 --"wdt:P131"--> v4
v3 --"wdt:P772"--> v1
v3 --"wdt:P131"--> v6
bind3[/"http://www.w3.org/2001/XMLSchema#integer(substring-after(str(?item1),'/Q'))"/]
v2 --o bind3
bind3 --as--o v7
bind4[/"http://www.w3.org/2001/XMLSchema#integer(substring-after(str(?item2),'/Q'))"/]
v3 --o bind4
bind4 --as--o v8
bind5[/"if(?q1 < ?q2,?item1,?item2)"/]
v7 --o bind5
v8 --o bind5
v2 --o bind5
v3 --o bind5
bind5 --as--o v9
bind6[/"if(?q1 < ?q2,?item2,?item1)"/]
v7 --o bind6
v8 --o bind6
v3 --o bind6
v2 --o bind6
bind6 --as--o v10
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c4 --"wikibase:language"--> c6
end