GraphStore`
GraphStore`

SPARQLAggregate

SPARQLAggregate["var"agg]

is a query operator that yields a solution containing the variable "var" whose value is computed from the aggregate agg.

SPARQLAggregate[{"var1"agg1,"var2"agg2,}]

yields a solution containing multiple aggregates.

SPARQLAggregate[aggs,groupby]

aggregates solutions grouped by the value of groupby.

SPARQLAggregate[aggs,groupby,having]

includes only groups for which having evaluates to True.

SPARQLAggregate[aggs,groupby,having,orderby]

orders groups by the value of orderby.

Details

  • An expression SPARQLSelect[]/*/*SPARQLAggregate[]/* can be used in SPARQLExecute to query a SPARQL endpoint.
  • SPARQLAggregate[] can be applied to the result of a SPARQLSelect query.
  • In SPARQLAggregate["var"agg], agg is usually of the form SPARQLEvaluation["f"][u1,u2,], where "f" is the name of a SPARQL aggregate function, and each ui is a SPARQLVariable whose associated values withing a solution group are supplied to the aggregate function.
  • Named SPARQL aggregate functions include:
  • "COUNT"counts the number of elements in a group
    "SUM"totals the values of a group
    "MIN"returns the minimum value in a group
    "MAX"returns the maximum value in a group
    "AVG"returns the averag of the values in a group
    "GROUP_CONCAT"joins String values of a group
    "SAMPLE"returns an arbitrary value from the group
  • SPARQLEvaluation["GROUP_CONCAT"][var, "Separator" -> "sep"] can be used to join strings using separator "sep". The default separator is " " (space).

Examples

open all close all

Basic Examples  (1)

In[1]:=
Click for copyable input

Data about fruits:

In[2]:=
Click for copyable input

The vocabulary:

In[3]:=
Click for copyable input

Count the fruits:

In[4]:=
Click for copyable input
Out[4]=

Find the number of fruits per color:

In[5]:=
Click for copyable input
Out[5]=

Scope  (4)

Generalizations & Extensions  (1)

Applications  (1)