← Aggregate Queries
Review COUNT, GROUP BY, and other aggregates.
Go BackGo beyond SELECT with alternative query forms. Check for data existence with ASK, generate new RDF with CONSTRUCT, and explore entities with DESCRIBE.
While SELECT queries return tabular results, SPARQL offers three additional
query forms for different use cases:
These forms are essential for data validation, RDF transformation, and building semantic web applications.
Test whether a pattern exists in the data. Returns a simple boolean true or false — perfect for validation and existence checks.
Learn ASKGenerate new RDF triples using a template. Transform data, create derived relationships, or convert between vocabularies.
Learn CONSTRUCTGet a description of resources. The endpoint decides what information to return — useful for exploring unknown entities.
Learn DESCRIBEASK {
wd:Q28865 wdt:P31 wd:Q9143 .
}
ASK {
?lang wdt:P31 wd:Q9143 ;
wdt:P571 ?inception .
FILTER(YEAR(?inception) > 2020)
}
CONSTRUCT {
?lang <http://example.org/createdIn> ?year .
?lang rdfs:label ?langLabel .
}
WHERE {
?lang wdt:P31 wd:Q9143 ;
wdt:P571 ?inception .
BIND(YEAR(?inception) AS ?year)
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
LIMIT 10
DESCRIBE wd:Q28865
| Query Form | Use When | Output |
|---|---|---|
SELECT |
You need tabular results with specific variables | Table (rows & columns) |
ASK |
You only need to know if data exists | Boolean (true/false) |
CONSTRUCT |
You need to create or transform RDF data | RDF graph (triples) |
DESCRIBE |
You want to explore an entity without knowing its structure | RDF graph (triples) |