Wikipedysta:Piastu/SPARQL
Z Wikipedii, wolnej encyclopedia
- grail
SELECT DISTINCT ?item ?itemLabel ?itemDescription ?value WHERE { ?item wdt:P3921/wdt:P279* ?value . SERVICE wikibase:label { bd:serviceParam wikibase:language "pl, en, [AUTO_LANGUAGE]" . } } # LIMIT 2000
- Łódź wg osiedli
#defaultView:Map SELECT ?item ?itemLabel ?parentLabel ?osiedleLabel ?dzielnicaLabel ?coords (?osiedleLabel as ?layer) WHERE { ?item wdt:P131 ?osiedle. ?osiedle wdt:P131 ?dzielnica. ?dzielnica wdt:P131 wd:Q580. ?item wdt:P625 ?coords. OPTIONAL {?item wdt:P361 ?parent.} SERVICE wikibase:label { d:serviceParam wikibase:language "pl, en". } } ORDER BY ASC(?osiedleLabel) ASC(?itemLabel)
- Poznański, galeria
#defaultView:ImageGrid SELECT ?item ?itemLabel ?parentLabel ?osiedleLabel ?dzielnicaLabel ?coords (?osiedleLabel as ?layer) ?pic WHERE { ?item wdt:P131 ?osiedle. #?osiedle wdt:P131 ?dzielnica. #?dzielnica wdt:P131 wd:Q580. ?item wdt:P361 wd:Q9257569. ?item wdt:P18 ?pic. ?item wdt:P625 ?coords. OPTIONAL {?item wdt:P361 ?parent.} SERVICE wikibase:label { bd:serviceParam wikibase:language "pl, en". } } ORDER BY ASC(?osiedleLabel) ASC (?itemLabel)
- hint: use hint for timeouts (uckie ulice)
#Hint – optimizer as a false friend SELECT DISTINCT ?item ?itemLabel WHERE { hint:Query hint:optimizer "None" . # bo po co komu optimizer :> po timeout ?item wdt:P131* wd:Q580 ; wdt:P31/wdt:P279* wd:Q34442. SERVICE wikibase:label { bd:serviceParam wikibase:language "pl, [AUTO_LANGUAGE]". } }
- rabini (refactor?)
SELECT DISTINCT ?rebe ?rebeLabel ?rebe_HE ?rebe_YI ?rebe_EN ?rebe_DE ?rebe_RU ?rebeDescription ?du ?muLabel ?ds ?msLabel WHERE { ?rebe wdt:P31 wd:Q5; wdt:P106/wdt:P279* wd:Q133485. OPTIONAL {?rebe wdt:P569 ?du.} OPTIONAL {?rebe wdt:P19 ?mu.} OPTIONAL {?rebe wdt:P570 ?ds.} OPTIONAL {?rebe wdt:P20 ?ms.} SERVICE wikibase:label { bd:serviceParam wikibase:language "pl". } SERVICE wikibase:label { bd:serviceParam wikibase:language "he". ?rebe rdfs:label ?rebe_HE. } hint:Prior hint:runLast false. SERVICE wikibase:label { bd:serviceParam wikibase:language "yi". ?rebe rdfs:label ?rebe_YI. } hint:Prior hint:runLast false. SERVICE wikibase:label { bd:serviceParam wikibase:language "en". ?rebe rdfs:label ?rebe_EN. } hint:Prior hint:runLast false. SERVICE wikibase:label { bd:serviceParam wikibase:language "de". ?rebe rdfs:label ?rebe_DE. } hint:Prior hint:runLast false. SERVICE wikibase:label { bd:serviceParam wikibase:language "ru". ?rebe rdfs:label ?rebe_RU. } hint:Prior hint:runLast false. } ORDER BY ASC (?rebeLabel)
SELECT DISTINCT ?rebe ?rebeLabel WHERE { ?rebe wdt:P31 wd:Q5; wdt:P106/wdt:P279* wd:Q133485. SERVICE wikibase:label { bd:serviceParam wikibase:language "pl". } } ORDER BY ASC (?rebeLabel)
- przeszukiwanie zawodów i płci po opisach
SELECT DISTINCT ?actor ?actorLabel ?actorDescription WHERE { ?actor wdt:P31 wd:Q5; wdt:P106/wdt:P279* wd:Q3455803; wdt:P21 wd:Q6581072; wdt:P27 wd:Q36; schema:description "polska reżyser"@pl. SERVICE wikibase:label { bd:serviceParam wikibase:language "pl, en". } }
- wyszukiwanie orcid
SELECT ?item ?itemLabel ?itemDescription ?ORCID WHERE { VALUES ?ORCID { "0000-0002-6904-5608" } ?item wdt:P496 ?ORCID. SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
- pochowani na starym
SELECT ?item ?itemLabel ?surnameLabel ?_image ?cLabel WHERE { ?item wdt:P119/wdt:P361* wd:Q4574095 ; wdt:P119 ?c . SERVICE wikibase:label { bd:serviceParam wikibase:language "pl, en, [AUTO_LANGUAGE]". } OPTIONAL { ?item wdt:P1442 ?_image . } OPTIONAL { ?item wdt:P734 ?surname . } } ORDER BY ASC(?c) ASC(?surnameLabel)
- stary do zakropkowania
#defaultView:Map{"hide":["?cLabel", "?coords"]} SELECT DISTINCT ?item ?itemLabel ?img ?idmiejsca (SAMPLE(?coords) AS ?coords) ?cLabel (?cLabel as ?layer) WHERE { { ?item wdt:P119/wdt:P361* wd:Q4574095 ; wdt:P119 ?c ; p:P119|p:P1442 [pq:P625 ?coords ] . OPTIONAL { ?item wdt:P1442 ?img . } OPTIONAL {?item p:P119 [pq:P965 ?idmiejsca].} } UNION { ?item wdt:P31/wdt:P279* wd:Q811979 ; wdt:P31 ?t ; wdt:P276/wdt:P361* wd:Q4574095 ; wdt:P276 ?c ; wdt:P625 ?coords . OPTIONAL { ?item wdt:P18 ?img . } FILTER(?t != wd:Q39614) } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], pl, en". } } GROUP BY ?item ?itemLabel ?img ?idmiejsca ?cLabel
- stary na czasówce (a to było tak)
#defaultView:Timeline SELECT ?item ?itemLabel ?itemDescription ?date ?image WHERE { { SELECT ?item ?date (SAMPLE(?_image) AS ?image) WHERE { ?item wdt:P119/wdt:P361* wd:Q4574095 . OPTIONAL{ ?item wdt:P570 ?date . } OPTIONAL{ ?item wdt:P1442 ?_image . } } GROUP BY ?item ?date ?image } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],pl,en,uk,ru" . } } ORDER BY DESC(?date)
- gatunki ptaków na plwiki
SELECT ?item ?taxonname ?iucn ?sitelink WHERE { ?item wdt:P31 wd:Q16521 ; wdt:P105 wd:Q7432 ; wdt:P171* wd:Q5113 ; wdt:P225 ?taxonname . OPTIONAL { ?item wdt:P627 ?iucn } . ?sitelink schema:about ?item ; schema:isPartOf <https://pl.wikipedia.org/> . } ORDER BY ASC(?iucn)
- liczba gatunków ptaków na WD i plwiki wg rzędów
SELECT (COUNT (?item) AS ?species) (COUNT (?itemPL) AS ?speciesPL) ((?species - ?speciesPL) AS ?diff) ?order ?orderName WHERE { ?item wdt:P31 wd:Q16521 ; wdt:P105 wd:Q7432 ; wdt:P171+ ?order ; wdt:P171+ wd:Q5113 ; wdt:P627 ?iucn . OPTIONAL {?itemPL schema:about ?item ; schema:isPartOf <https://pl.wikipedia.org/> . } { SELECT ?order ?orderName WHERE { ?order wdt:P31 wd:Q16521 ; wdt:P105 wd:Q36602 ; wdt:P171+ wd:Q5113 ; wdt:P225 ?orderName . } } } GROUP BY ?order ?orderName ORDER BY DESC (?species)
- obrazy (pewnie nie tylko) po opisie
SELECT ?item ?label WHERE { ?item wdt:P170 wd:Q943537 ; schema:description "obraz Leon Wyczółkowski"@pl. SERVICE wikibase:label { bd:serviceParam wikibase:language "pl" . ?item rdfs:label ?label } } LIMIT 1000
- obrazy z krakowskiego MN (z pominięciem anonimów)
SELECT ?item ?itemLabel ?itemDescription WHERE { ?item wdt:P195 wd:Q195311; wdt:P170 ?autor. FILTER (?autor != wd:Q4233718) SERVICE wikibase:label { bd:serviceParam wikibase:language "pl, en". } } LIMIT 1000
- architekci warszawscy
SELECT #?budynek #?budynekLabel ?architekt ?architektLabel WHERE { ?budynek wdt:P31/wdt:P279* wd:Q41176; wdt:P131/wdt:P279* wd:Q270; wdt:P84/wdt:P279* ?architekt. # ?budynek wdt:P131/wdt:P279* ?jednostka. SERVICE wikibase:label { bd:serviceParam wikibase:language "pl". } } GROUP BY ?architekt ?architektLabel
- PLWABN + plwiki arts
SELECT ?item ?plwabn ?cc ?sitelink WHERE { ?item wdt:P7293 ?plwabn. OPTIONAL {?item wdt:P373 ?commons_cat . } BIND(uri(concat("https://commons.wikimedia.org/wiki/Category:", ?commons_cat)) AS ?cc) ?sitelink schema:about ?item; schema:isPartOf <https://pl.wikipedia.org/>. }
- mass desc changes
SELECT #?item ?q ?descPl ?new_desc WHERE { ?item schema:description "obraz anonim"@pl. BIND("Dpl" AS ?descPl) BIND('"obraz nieznanego autora"' AS ?new_desc) BIND(SUBSTR(STR(?item), 32) AS ?q) # SERVICE wikibase:label { bd:serviceParam wikibase:language "pl" . } } # LIMIT 1000
- II
- podobnie, tylko z kitkom
SELECT ?q ?descPl ?new_desc ?taxon # ?item WHERE { ?item wdt:P31 wd:Q16521 ; wdt:P105 wd:Q7432 ; wdt:P171* wd:Q9482 ; wdt:P225 ?taxon . BIND("Dpl" AS ?descPl) BIND('"gatunek gryzonia z rodziny wiewiórkowatych"' AS ?new_desc) BIND(SUBSTR(STR(?item), 32) AS ?q) }
- stoliczne przystanki
SELECT ?item ?itemLabel ?typ $date_start ?date_end ?jednLabel ?image WHERE { VALUES (?przystanki ?typ) { (wd:Q953806 "A") (wd:Q2175765 "T") } ?item wdt:P31 ?przystanki ; wdt:P131+ wd:Q270 ; wdt:P131 ?jedn. SERVICE wikibase:label { bd:serviceParam wikibase:language "pl" . } OPTIONAL { ?item wdt:P18 ?image. } OPTIONAL { ?item wdt:P571 ?date_start . } OPTIONAL { ?item wdt:P576 ?date_end . } } ORDER BY DESC(?date_start) DESC(?date_end) ASC(?jednLabel) LIMIT 1000
- lajkonikowe Jacki
#defaultView:Graph SELECT ?item ?itemLabel ?item_image ?collection ?collectionLabel ?who ?whoLabel ?model ?modelLabel WHERE { VALUES ?muzeum { wd:Q195311 wd:Q18820 } # Q195311-MNK Q18820-Wawel ?item wdt:P170 wd:Q448189 ; wdt:P195 ?muzeum . # OPTIONAL {?item wd:P2634 ?model . } OPTIONAL { ?item wdt:P180 ?who . } # P921-główny temat P180-przedstawia OPTIONAL { ?item wdt:P195 ?collection . } # P195-kolekcja P276-miejsce SERVICE wikibase:label { bd:serviceParam wikibase:language "pl" . } OPTIONAL { ?item wdt:P18 ?item_image. } } LIMIT 30
- zbiory MS Uć
SELECT ?item ?itemLabel (GROUP_CONCAT(DISTINCT ?typeLabel; separator=", ") AS ?types ) ?itemDescription ?authorLabel ?placeLabel WHERE { SELECT ?item ?itemLabel ?typeLabel ?itemDescription ?authorLabel ?placeLabel WHERE { ?item wdt:P31/wdt:P279* wd:Q838948 ; wdt:P195 wd:Q1141934 ; wdt:P31 ?type . OPTIONAL {?item wdt:P170 ?author . } OPTIONAL {?item wdt:P276 ?place . } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], pl, en, ru, de, fr" . } } } GROUP BY ?item ?itemLabel ?itemDescription ?authorLabel ?placeLabel ORDER BY ASC(?authorLabel)
- cośtam
SELECT ?q ?pfff ?bohater # ?item ?itemLabel ?itemDescription ?sitelink WHERE { VALUES ?order { wd:Q749849 wd:Q4335914 } ?item wdt:P166 ?order ; wdt:P166 wd:Q1358055. BIND(CONCAT("-", SUBSTR(STR(?item), 32)) AS ?q) BIND("P166" AS ?pfff) BIND("Q1358055" AS ?bohater) # SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], pl, en, uk" . } # ?sitelink schema:about ?item ; # schema:isPartOf <https://pl.wikipedia.org/> . }
SELECT ?item ?itemLabel ?countryLabel (GROUP_CONCAT(DISTINCT ?cLabel; separator=", ") AS ?cities ) ?sitelink (GROUP_CONCAT(DISTINCT ?tLabel; separator=", ") AS ?types ) WHERE { ?item wdt:P31/wdt:P279* wd:Q4989906 ; wdt:P180 wd:Q1268 ; wdt:P17 ?country ; wdt:P131 ?c ; wdt:P31 ?t . SERVICE wikibase:label { bd:serviceParam wikibase:language "pl, en, uk, ru" . } SERVICE wikibase:label { bd:serviceParam wikibase:language "pl, en, uk, ru". ?t rdfs:label ?tLabel. ?c rdfs:label ?cLabel. } OPTIONAL { ?sitelink schema:about ?item ; schema:isPartOf <https://pl.wikipedia.org/> . } } GROUP BY ?item ?itemLabel ?countryLabel ?sitelink ORDER BY ASC(?countryLabel) ASC(?cities)
- poczet Adasiów
#poczet Adasiów SELECT DISTINCT ?film ?filmLabel ?filmDescription ?actorLabel ?actor { ?film wdt:P31/wdt:P279* wd:Q11424; p:P161 [ ps:P161 ?actor; pq:P453 wd:Q9140733]. OPTIONAL {?film wdt:P577 ?premiera.} SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en". } } ORDER BY ?premiera
- don't look on Your rank, You are pretty to me…
SELECT ?item ?itemLabel ?rank ?date { ?item p:P31/ps:P31 wd:Q114716986. # ?item p:P31/ps:P31/wdt:P279* wd:Q114716986. # ?item p:P31 ?type. # ?type ps:P31 ?value. # ?type wikibase:rank ?rank. # ?type wikibase:rank wikibase:NormalRank. OPTIONAL {?item wdt:P580 ?date.} SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], pl, en" . } } ORDER BY DESC(?itemLabel)
- łódzkie bazgroły na murach
SELECT DISTINCT ?item ?itemLabel ?itemDescription ?authorLabel ?coords ?date ?_image { ?item wdt:P31 wd:Q219423; wdt:P131* wd:Q580. # MINUS {?item wdt:P31 wd:Q15893266.} OPTIONAL {?item wdt:P170 ?author.} OPTIONAL {?item wdt:P571 ?date.} OPTIONAL {?item wdt:P625 ?coords.} OPTIONAL { ?item wdt:P18 ?_image. } SERVICE wikibase:label {bd:serviceParam wikibase:language "pl, en" .} } ORDER BY DESC(?date)
- muzea w Europie, no, w kawałku
#defaultView:Map SELECT DISTINCT ?item ?itemLabel ?coords (?country as ?layer) { VALUES ?country {wd:Q37 wd:Q211 wd:Q191 wd:Q36 wd:Q184 wd:Q212 wd:Q213 wd:Q214 wd:Q217 wd:Q207272} ?item wdt:P17 ?country . wd:Q33506 ^wdt:P279*/^wdt:P31 ?item . ?item wdt:P625 ?coords. SERVICE wikibase:label { bd:serviceParam wikibase:language "pl, en" .} }
- listowanko wyburzanka
SELECT ?item ?itemLabel ?st WHERE { ?item wdt:P31 wd:Q19860854; wdt:P131* wd:Q580; p:P1435 ?st. ?st ps:P1435 ?value . ?st wikibase:rank wikibase:DeprecatedRank. SERVICE wikibase:label { bd:serviceParam wikibase:language "pl" . } }
- zbędne kategorie komąs do wycięcia QSem
SELECT ?q ?komons_cat ?unwanted_plaques WHERE { ?item wdt:P373 "Plaques in Aberdeen". BIND(CONCAT("-", SUBSTR(STR(?item), 32)) AS ?q) BIND("P373" AS ?komons_cat) BIND('"Plaques in Aberdeen"' AS ?unwanted_plaques) }
- podmianka opisów Opola, do rozszerzenia o rok kiedyś
SELECT * { { SELECT * { ?item wdt:P179 wd:Q479102 . BIND("Dpl" AS ?descPl). # BIND("P585" AS ?p). OPTIONAL {?item wdt:P393 ?edycja.} OPTIONAL {?item wdt:P585 ?data.} BIND(CONCAT("\"", ?edycja, ". edycja polskiego festiwalu muzycznego w Opolu w ", STR(YEAR(?data)), " roku\"" ) AS ?new_desc) BIND(SUBSTR(STR(?item), 32) AS ?q) BIND(1962 + xsd:integer(?edycja) AS ?new_date) BIND(IF (xsd:integer(?edycja) >= 20, (xsd:integer(?new_date) + 1), (xsd:integer(?new_date))) AS ?new_dateeee) } ORDER BY (xsd:integer(?edycja)) } SERVICE wikibase:label { bd:serviceParam wikibase:language "pl, en" . ?item rdfs:label ?label . ?item schema:description ?description . } }
- podsumowanie liczby identyfikatorów zewn.
# SELECT (SUM(?ids_count) AS ?sum) WHERE { SELECT ?item (COUNT(?prop) AS ?ids_count) WHERE { VALUES ?item { wd:Q124957990 wd:Q124808341 wd:Q124808658 } ?item wdt:P21 wd:Q6581072. ?item ?a []. ?prop wikibase:propertyType wikibase:ExternalId ; wikibase:directClaim ?a . # SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } GROUP BY ?item #?itemLabel # }