SPARQL examples: Difference between revisions
Appearance
Query examples for the query.ronzz.org GUI (public, anonymous-readable — the GUI fetches this page via action=parse) (via create-page on MediaWiki MCP Server) |
Keep the SPARQL acronym capitalised in Copy internal mention (Category:Proper name) (via update-page on MediaWiki MCP Server) |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
This page feeds the '''Examples''' dialog of the [https://query.ronzz.org RonzzWiki Query Service]. Each example is a self-contained SPARQL query against the RonzzWiki data (prefixes must be declared — see [[ | This page feeds the '''Examples''' dialog of the [https://query.ronzz.org RonzzWiki Query Service]. Each example is a self-contained SPARQL query against the RonzzWiki data (prefixes must be declared — see [[Cheatsheet:SPARQL]]). | ||
== People == | == People == | ||
| Line 98: | Line 98: | ||
} GROUP BY ?class ?classLabel ORDER BY DESC(?count) LIMIT 20 | } GROUP BY ?class ?classLabel ORDER BY DESC(?count) LIMIT 20 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Proper name]] | |||
Latest revision as of 11:54, 19 October 2026
This page feeds the Examples dialog of the RonzzWiki Query Service. Each example is a self-contained SPARQL query against the RonzzWiki data (prefixes must be declared — see Cheatsheet:SPARQL).
People
All people
PREFIX wd: <https://wikibase.ronzz.org/entity/>
PREFIX wdt: <https://wikibase.ronzz.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?person ?personLabel WHERE {
?person wdt:P1 wd:Q6 .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
} LIMIT 50
Books and sources
Books with their authors
PREFIX wd: <https://wikibase.ronzz.org/entity/>
PREFIX wdt: <https://wikibase.ronzz.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?book ?bookLabel ?authorLabel WHERE {
?book wdt:P1 wd:Q9 ;
wdt:P6 ?author .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
} LIMIT 50
Books with their publisher
PREFIX wd: <https://wikibase.ronzz.org/entity/>
PREFIX wdt: <https://wikibase.ronzz.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?book ?bookLabel ?publisherLabel WHERE {
?book wdt:P1 wd:Q9 ;
wdt:P54 ?publisher .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
} LIMIT 50
Books published after 2000
PREFIX wd: <https://wikibase.ronzz.org/entity/>
PREFIX wdt: <https://wikibase.ronzz.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?book ?bookLabel ?date WHERE {
?book wdt:P1 wd:Q9 ;
wdt:P8 ?date .
FILTER(YEAR(?date) >= 2000)
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
} ORDER BY DESC(?date) LIMIT 50
Software
Free and open-source software with developers and licenses
PREFIX wd: <https://wikibase.ronzz.org/entity/>
PREFIX wdt: <https://wikibase.ronzz.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?software ?softwareLabel ?developerLabel ?licenseLabel WHERE {
?software wdt:P1 wd:Q179 .
OPTIONAL { ?software wdt:P33 ?developer . }
OPTIONAL { ?software wdt:P34 ?license . }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
} LIMIT 50
Summary
How many items per class
PREFIX wd: <https://wikibase.ronzz.org/entity/>
PREFIX wdt: <https://wikibase.ronzz.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?class ?classLabel (COUNT(?item) AS ?count) WHERE {
?item wdt:P1 ?class .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
} GROUP BY ?class ?classLabel ORDER BY DESC(?count) LIMIT 20