query-9e7b87cdb0e6b4f8d268993abcd8ee6e
11:18, 30 December 2018 (UTC) Jura to p31-statements on these items, not all countries appeared. Also, to ensure you get same unit for area, I added the format in meter. --- rankI added an edited version above. As some added preferred 08:07, 31 December 2018 (UTC) JuraIt has three values. The easy fix is to comment out the line with (wdt:P2046) to avoid combining them with ?area2 they don't belong (done above). One could also use p:P2046 and map it correctly. --- 14:10, 30 December 2018 (UTC)) talk (BouzinacMINUS { ?country wdt:P582 :b3. } MINUS { ?country wdt:P576 :b2. } # remove items with P576 (dissolved, abolished or demolished) as a main property I would add the filters ; 12:16, 30 December 2018 (UTC)) talk (Strainu! I understand the first change, but I'm not sure about the second. It returns some weird results for Russia, especially if you drop the "DINSTINCT".--Jura1Thanks
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 psn: <http://www.wikidata.org/prop/statement/value-normalized/>
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 DISTINCT ?country ?countryLabel (ROUND(COALESCE(?area3, ?area2)/1000000) as ?area_km2) ?part ?partLabel
{
?country p:P31/ps:P31 wd:Q6256 .
?country wdt:P30 wd:Q46 .
?country p:P2046 / psn:P2046 [ wikibase:quantityAmount ?area2 ] .
OPTIONAL { ?country p:P30 [ pq:P518 ?part ; ps:P30 wd:Q46 ] .
?part p:P2046 / psn:P2046 [ wikibase:quantityAmount ?area3 ] .
}
MINUS { ?country wdt:P576 [] }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER by desc(?area_km2)