Intro to SPARQL (Part4)

sachini ranasinghe
2 min readDec 27, 2019

Numerical operations using MAX, MIN, COUNT, SUM and AVG keywords.

These keywords are executing very basic operations regarding the numerical calculations. But, they can be used for more complex numerical operations in complex queries. They perform exactly the same function which is in the keyword itself.

  • MAX gives the maximum of a given set of integer values.
  • MIN gives minimum of a given set of integer values.
  • COUNT counts number of triples returned.
  • SUM gives the sum of a set of integer values.
  • AVG gives the average of a set of integer values.

As the control example we have the result of the query without any of these operations. As you can see we have 3 caloric values.

normal select query

MAX

return maximum caloric value

MIN

return minimum caloric value

COUNT

return the count of results returned

SUM

sum of all values returned for ?caloryvalue

AVG

return average of the results returned for ?caloryvalue

What should keep in mind is, these queries may contain many other conditions ,ANDed to create complex queries. These are just simplest representations of each keyword created for better understanding of a beginner.

As the next part of this series I hope to describe about the GROUP BY and HAVING keywords.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response