GraphKnowledge

graph-lakehouse

SELECT

Like SQL, SPARQL provides a SELECT query form for selecting or finding data. This section describes the SELECT form.

Syntax

[ PREFIX Clause ] SELECT [ DISTINCT | REDUCED ] result_expressions_and_variables [ FROM Clause ] WHERE Clause [ Solution Modifiers ]

The optional DISTINCT solution sequence modifier eliminates duplicate results. The REDUCED modifier permits duplicate solutions to be removed but does not guarantee that they are eliminated from the results.

Examples

The following simple SELECT statement queries the sample Tickit data set to return all of the predicates and objects for event100:

SELECT ?predicate ?object FROM http://anzograph.com/tickit WHERE { http://anzograph.com/tickit/event100 ?predicate ?object } ORDER BY ?predicate

predicate | object ------------------------------------------------+--------------------------------------- http://anzograph.com/tickit/catid | http://anzograph.com/tickit/category8 http://anzograph.com/tickit/dateid | http://anzograph.com/tickit/date2129 http://anzograph.com/tickit/eventname | Siegfried http://anzograph.com/tickit/starttime | 2008-10-30T15:00:00Z http://anzograph.com/tickit/venueid | http://anzograph.com/tickit/venue300 http://www.w3.org/1999/02/22-rdf-syntax-ns#type | http://anzograph.com/tickit/event 6 rows

This simple SELECT statement uses the DISTINCT modifier to list each distinct event name in the Tickit data set:

SELECT DISTINCT ?name FROM http://anzograph.com/tickit WHERE { ?event http://anzograph.com/tickit/eventname ?name. }

name

Adriana Lecouvreur Eugene Onegin La Cenerentola (Cinderella) A Chorus Line Hairspray Le Reve Hedda Gabler Endgame Othello Miss Julie ... 576 rows

This example queries the sample Tickit data set to select the top 10 listings where the price per ticket is greater than $500.00:

SELECT ?listing ?priceperticket FROM http://anzograph.com/tickit WHERE { ?listing http://anzograph.com/tickit/listtime ?listtime . ?listing http://anzograph.com/tickit/priceperticket ?priceperticket . FILTER(?priceperticket > 500.00) } ORDER BY desc(?priceperticket) LIMIT 10

listing | priceperticket ------------------------------------------+---------------- http://anzograph.com/tickit/listing227412 | 2500 http://anzograph.com/tickit/listing222840 | 2500 http://anzograph.com/tickit/listing225362 | 2500 http://anzograph.com/tickit/listing214995 | 2500 http://anzograph.com/tickit/listing209658 | 2500 http://anzograph.com/tickit/listing211035 | 2500 http://anzograph.com/tickit/listing213613 | 2500 http://anzograph.com/tickit/listing215156 | 2500 http://anzograph.com/tickit/listing210898 | 2500 http://anzograph.com/tickit/listing224389 | 2500 10 rows

Source: https://docs.sw.siemens.com/documentation/external/PL20260518131381558/en-US/html/select.htm · retrieved 2026-08-23