SQL
AخA
SELECT
?item ?name ?lat ?long ?typelabel ?vaid ?year ?image ?commonscat ?municipality
?district ?locality ?complex ?region ?address ?wikipediauri ?extlink ?munwiki
WHERE
{
VALUES ?currList { wd:Q20968310 } .
VALUES ?currNovads { wd:Q178382 } .
?currNovads wdt:P300 ?region .
?item wdt:P2817 ?currList .
?item wdt:P2494 ?vaid .
?item wdt:P1435 ?type .
?item wdt:P131 ?munid.
?munid wdt:P131 ?upmunid .
?munid wdt:P131* ?currNovads .
?upmunid wdt:P31 ?upmuntype .
BIND ( IF ( ( ?upmuntype = wd:Q2577184) , ?upmunid , ?munid ) AS ?novads ) .
?munsitelink schema:about ?munid .
?munsitelink schema:inLanguage "lv" .
BIND(STRAFTER(str(?munsitelink), "lv.wikipedia.org/wiki/") AS ?munwiki) .
OPTIONAL { ?item wdt:P373 ?commonscat } .
OPTIONAL { ?item wdt:P2795 ?locality} .
OPTIONAL { ?item wdt:P361 ?complex } .
OPTIONAL { ?item p:P571 ?inception . ?inception pq:P1932 ?year } .
OPTIONAL { ?item wdt:P18 ?pic . BIND(STRAFTER(str(?pic), "Special:FilePath/") AS ?image) . }
OPTIONAL { ?item wdt:P856 ?extlink } .
OPTIONAL { ?item wdt:P6375 ?address } .
OPTIONAL { ?item wdt:P625 ?coord .
?item p:P625 ?coordinate .
?coordinate psv:P625 ?coordinate_node .
?coordinate_node wikibase:geoLatitude ?lat .
?coordinate_node wikibase:geoLongitude ?long . }
OPTIONAL { ?sitelink schema:about ?item . ?sitelink schema:inLanguage "lv"
BIND(strafter(str(?sitelink),"/wiki/") as ?wikipediauri) }
?item rdfs:label ?name . FILTER(lang(?name)="lv")
?type rdfs:label ?typelabel . FILTER(lang(?typelabel)="lv")
?munid rdfs:label ?municipality . FILTER(lang(?municipality)="lv")
?novads rdfs:label ?district . FILTER(lang(?district)="lv")
By running queries you agree to the Cloud Services Terms of Use and you irrevocably agree to release your SQL under CC0 License.
All SQL code is licensed under CC0 License.