Project:SPARQL query service/queries/examples: Difference between revisions
From SCDB
m (Myst moved page MediaWiki:SPARQL query service/queries/examples to Project:SPARQL query service/queries/examples) |
No edit summary |
||
Line 33: | Line 33: | ||
} | } | ||
GROUP BY ?item ?itemLabel | GROUP BY ?item ?itemLabel | ||
}} | |||
=== Manufacturers with their ships === | |||
{{SPARQL2|query=#defaultView:Tree | |||
SELECT ?manufacturer ?manufacturerLabel ?item ?itemLabel | |||
WHERE | |||
{ | |||
?item scdbt:P1 scdb:Q842; | |||
scdbt:P23 ?manufacturer. | |||
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } | |||
} | |||
}} | }} | ||
Revision as of 17:22, 19 July 2020
Simple Queries
These basic queries help to understand SPARQL and the Wikibase RDF format.
Ships
SELECT ?item ?itemLabel
WHERE
{
?item scdbt:P1 scdb:Q842.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Ships ordered by cargo capacity
SELECT ?item ?itemLabel ?cargoCapacity WHERE
{
?item scdbt:P1 scdb:Q842;
scdbt:P61 ?cargoCapacity.
FILTER(0 < ?cargoCapacity).
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY DESC(?cargoCapacity)
List manufacturers with manufacturer type
SELECT ?item ?itemLabel (GROUP_CONCAT(DISTINCT(?instanceLabel); separator=", ") as ?instances) WHERE {
?item scdbt:P1/scdbt:P26* scdb:Q843;
scdbt:P1 ?instance .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" .
?item rdfs:label ?itemLabel .
?instance rdfs:label ?instanceLabel
}
}
GROUP BY ?item ?itemLabel
Manufacturers with their ships
#defaultView:Tree
SELECT ?manufacturer ?manufacturerLabel ?item ?itemLabel
WHERE
{
?item scdbt:P1 scdb:Q842;
scdbt:P23 ?manufacturer.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Search by label
SELECT ?item ?itemLabel WHERE {
?item rdfs:label ?itemLabel.
FILTER(REGEX(?itemLabel, "^Ballista.*", "i"))
}
LIMIT 10
List of systems
SELECT ?item ?itemLabel WHERE {
?item scdbt:P1 scdb:Q16.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
List of jump points of Stanton system
SELECT ?item ?itemLabel WHERE {
?item scdbt:P1 scdb:Q916;
scdbt:P48 scdb:Q24.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
STAR arkmap type
SELECT ?item ?itemLabel
WHERE
{
?item scdbt:P10 "STAR".
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
List everything from Query Service
SELECT ?item ?itemLabel
WHERE {
?item rdfs:label ?itemLabel.
} ORDER BY ?item