MIN
The MIN function returns the minimum value from the specified set of values.
MIN Syntax
Use the following syntax when incorporating the MIN function in queries:
MIN(expression)
Where expression evaluates to any data type except for boolean.
Note: A GROUP BY statement is required for queries that contain MIN functions if the results clause lists non-aggregate variables. Include all non-aggregated variables in the GROUP BY statement.
MIN Examples
The example queries in this section run against the AnzoGraph sample Tickit data set, which captures sales activity for a fictional Tickit website where people buy and sell tickets for sporting events, shows, and concerts. You can load and explore this data set. For more information, see Working with the Tickit Data.
The following example queries the sample Tickit data to list the 10 events with the lowest price paid for tickets:
SELECT ?event (MIN(?paid) AS ?min_paid) FROM <tickit> WHERE { ?s <pricepaid> ?paid . ?s <eventid> ?id . ?id <eventname> ?event . } GROUP BY ?event ORDER BY ?min_paid LIMIT 10
event | min_paid -------------------------+----------- Huey Lewis and the News | 20.000000 Bad Company | 20.000000 Al Green | 20.000000 Bloc Party | 20.000000 Hamlet | 20.000000 Hairspray | 20.000000 George Jones | 20.000000 Shrek the Musical | 20.000000 Thurgood | 20.000000 Oliver Dragojevic | 20.000000 10 rows