SPARQL examples: Difference between revisions

From Dariah-Lab
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
<languages />
{{Warning|1=<translate><!--T:1--> Editing this page will change the examples shown on <tvar name=1>[https://query.wikidata.org query.wikidata.org]</tvar></translate>}}
{{Notice|1=<translate><!--T:2--> Please help to improve this page! Phabricator task <tvar name=1>[https://phabricator.wikimedia.org/T132690 T132690]</tvar></translate>}}
{{Notice|1=<translate><!--T:3--> Feel free to add your example, or edit an existing one, if you think it is useful</translate> }}
<!--T:4-->
<!--T:4-->
This page is parsed by the web interface of the query service to fill the query example dialog.  
This page is parsed by the web interface of the query service to fill the query example dialog.  


__TOC__
== <!--T:9--> Simple queries ==
{{Translation categories|Wikidata:SPARQL query service}}
{{#if:{{#translation:}}||
[[Category:SPARQL]]
[[Category:Exploring Wikidata]]
}}


== <translate><!--T:9--> Simple queries</translate> ==
=== <!--T:541--> Institutions ===
 
=== <translate><!--T:541--> Institutions</translate> ===
{{SPARQL|query=SELECT SELECT ?institution ?institutionLabel  
{{SPARQL|query=SELECT SELECT ?institution ?institutionLabel  
WHERE  
WHERE  
Line 24: Line 11:
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # <translate><!--T:681--> Helps get the label in your language, if not, then en language</translate>
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # <translate><!--T:681--> Helps get the label in your language, if not, then en language</translate>
}
}
}}
== <!--T:683--> External identifiers ==
=== <translate><!--T:684--> Swedish municipalities which changed their municipality identifier at some point</translate> ===
<translate><!--T:685--> This is an example of an identifier which is unstable over time and thus unsuitable to be used as an identifier in e.g. an IT-system.</translate>
{{SPARQL|query=
#title:Swedish municipalities which changed their municipality identifier at some point
#author:Salgo60 2021-09-11
SELECT DISTINCT ?item ?itemLabel  ?kkod1 ?kkod2  ?svwp_artikel WHERE
{
  ?item wdt:P525 ?kkod1 .
  ?item wdt:P525 ?kkod2 .
  FILTER ( ?kkod1<?kkod2 )
  SERVICE wikibase:label { bd:serviceParam wikibase:language "sv". }
  OPTIONAL { ?svwp_artikel schema:about ?item; schema:isPartOf <https://sv.wikipedia.org/> }
}
ORDER BY ?itemLabel
}}
}}

Revision as of 14:27, 10 May 2022

This page is parsed by the web interface of the query service to fill the query example dialog.

Simple queries

Institutions

Template:SPARQL