query-380aa330d40bd765ba0fda8e014c03e6
18:29, 19 February 2018 (UTC)) talk (Doc Taxon: this orders the result first by ?links descending and then by ?item ascending. But ?item has been ordered alphabetically, how can it be ordered integer? Larske, MisterSynergy@ 20:31, 19 February 2018 (UTC)) talk (Doc TaxonThe first request above gives actually 45420 results, the last request above gives actually 45398. Where are the missing 22 results? Some modifications:
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 schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?item ?itemLabel ?num (COUNT(?sitelink) AS ?sitelinks) WHERE {
{
SELECT DISTINCT ?item WHERE {
VALUES ?item_class { wd:Q34 wd:Q183 }
?item wdt:P27 ?item_class; wdt:P21 wd:Q6581072; wdt:P31 wd:Q5 .
}
}.
?item rdfs:label ?itemLabel .
FILTER(LANG(?itemLabel) = 'fr') .
BIND(xsd:integer(SUBSTR(STR(?item), 33)) AS ?num) .
OPTIONAL { ?sitelink schema:about ?item; schema:isPartOf [ wikibase:wikiGroup 'wikipedia' ] }
} GROUP BY ?item ?itemLabel ?num ORDER BY DESC(?sitelinks) ASC(?num)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?item"):::projected
v3("?itemLabel"):::projected
v4("?item_class")
v6("?num"):::projected
v6("?sitelink"):::projected
v7("?sitelinks")
a1((" "))
c6(["wd:Q5"]):::iri
c4(["wd:Q6581072"]):::iri
c10(["wikipedia"]):::literal
f0[["?itemLabel = 'fr'"]]
f0 --> v3
bind1[/VALUES ?item_class/]
bind1-->v4
bind10(["wd:Q34"])
bind10 --> bind1
bind11(["wd:Q183"])
bind11 --> bind1
v5 --"wdt:P27"--> v4
v5 --"wdt:P21"--> c4
v5 --"wdt:P31"--> c6
v5 --"rdfs:label"--> v3
bind2[/"http://www.w3.org/2001/XMLSchema#integer(substring(str(?item),'33^^xsd:integer'))"/]
v5 --o bind2
bind2 --as--o v6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v6 -."schema:about".-> v5
a1 --"wikibase:wikiGroup"--> c10
v6 --"schema:isPartOf"--> a1
end
bind4[/"count(?sitelink)"/]
v6 --o bind4
bind4 --as--o v7