Project:SPARQL/examples: Difference between revisions

no edit summary
No edit summary
(3 intermediate revisions by the same user not shown)
Line 130: Line 130:


=Topics=
=Topics=
==Timeline of everything about a topic==
<SPARQL tryit="1">
#defaultView:Timeline
PREFIX wb: <https://metabase.wikibase.cloud/entity/>
PREFIX wbt: <https://metabase.wikibase.cloud/prop/direct/>
SELECT ?item ?itemLabel ?time
WHERE
{
?item wbt:P15 wb:Q90 # SDC
{?item wbt:P23 ?time} # point in time
UNION
{?item wbt:P18 ?time} # publication date
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,sv". }
}
</SPARQL>
==Topics of the sessions at the GLAM Wiki 2023 conference==
==Topics of the sessions at the GLAM Wiki 2023 conference==
<SPARQL tryit="1">
<SPARQL tryit="1">
Line 145: Line 160:
ORDER BY DESC(?count)
ORDER BY DESC(?count)
</SPARQL>
</SPARQL>
=Events=
=Events=
==Most common locations for WMSE events==
==Most common locations for WMSE events==
Line 247: Line 263:


= Federated queries =
= Federated queries =
== Everything that took place in a certain country==
<SPARQL tryit="1">
PREFIX wb: <https://metabase.wikibase.cloud/entity/>
PREFIX wbt: <https://metabase.wikibase.cloud/prop/direct/>
SELECT DISTINCT ?item ?itemLabel ?place ?placeLabel
WHERE
{
?item wbt:P27 ?place.
?place wbt:P1 ?wikidataQ.
BIND(URI(concat("http://www.wikidata.org/entity/", ?wikidataQ)) AS ?wikidata_iri)
SERVICE <https://query.wikidata.org/sparql> {
?wikidata_iri wdt:P17 wd:Q34. # Sweden
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". }
}
ORDER BY ?placeLabel
</SPARQL>
== Map of all event locations ==
== Map of all event locations ==
<SPARQL tryit="1">
<SPARQL tryit="1">
Line 362: Line 397:
PREFIX wbt: <https://metabase.wikibase.cloud/prop/direct/>
PREFIX wbt: <https://metabase.wikibase.cloud/prop/direct/>


SELECT ?subject ?subjectLabel
SELECT ?item ?itemLabel ?subject ?subjectLabel
WHERE
WHERE
{
{
?item wb:P15 ?subject.
?item wbt:P15 ?subject.
MINUS {?subject wb:P5 wbt:Q12}
FILTER NOT EXISTS {?subject wbt:P5 wb:Q12}
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". }
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". }
}
}