@@ -9732,10 +9732,10 @@ <h5>Count</h5>
9732
9732
has a bound, non-error value within the aggregate group.</p>
9733
9733
<div class="defn">
9734
9734
<p><b>Definition: <span id="defn_aggCount">Count</span></b></p>
9735
- <pre class="code nohighlight">xsd:integer Count(sequence S )</pre>
9736
- <p>L = Flatten(S) </p>
9737
- <p>remove error elements from L</p>
9738
- <p>Count(S) = <a href="#defn_Card">Card</a>(L) </p>
9735
+ <pre class="code nohighlight">xsd:integer <var> Count</var> (sequence <var>S</var> )</pre>
9736
+ <p><var>Count</var>(<var>S</var>) = <a href="#defn_Card">Card</a>(<var>L'</var>), </p>
9737
+ <p>where <var>L'</var> is the list <var> L</var> = <a href="#defn_Flatten">Flatten</a>(<var>S</var>)
9738
+ with all error elements removed. </p>
9739
9739
</div>
9740
9740
</section>
9741
9741
<section id="aggSum">
@@ -9749,7 +9749,7 @@ <h5>Sum</h5>
9749
9749
<p><b>Definition: <span id="defn_aggSum">Sum</span></b></p>
9750
9750
<pre class="code nohighlight">numeric <var>Sum</var>(sequence <var>S</var>)</pre>
9751
9751
<p><var>Sum</var>(<var>S</var>) = <var>SumList</var>(<var>L</var>),</p>
9752
- <p>where <var>L</var> = Flatten(<var>S</var>) and
9752
+ <p>where <var>L</var> = <a href="#defn_Flatten"> Flatten</a> (<var>S</var>) and
9753
9753
<var>SumList</var>(<var>L</var>) is defined recursively as follows.</p>
9754
9754
<ul>
9755
9755
<li>If <a href="#defn_Card">Card</a>(<var>L</var>) = 0, then
@@ -9773,11 +9773,17 @@ <h5>Avg</h5>
9773
9773
average value for an expression over a group. It is defined in terms of Sum and Count.
9774
9774
<div class="defn">
9775
9775
<p><b>Definition: <span id="defn_aggAvg">Avg</span></b></p>
9776
- <pre class="code nohighlight">numeric Avg(sequence S)</pre>
9777
- <p>Avg(S) = "0"^^xsd:integer if Count(S) = 0</p>
9778
- <p>Avg(S) = Sum(S) / Count(S) if Count(S) > 0</p>
9779
- </div>
9780
- <p>For example, Avg([(1), (2), (3)]) = Sum([(1), (2), (3)])/Count([(1), (2), (3)]) = 6/3 = 2.</p>
9776
+ <pre class="code nohighlight">numeric <var>Avg</var>(sequence <var>S</var>)</pre>
9777
+ <p>If <var><a href="#defn_aggCount">Count</a></var>(<var>S</var>) = 0,
9778
+ then <var>Avg</var>(<var>S</var>) = "0"^^<code>xsd:integer</code>.</p>
9779
+ <p>If <var><a href="#defn_aggCount">Count</a></var>(<var>S</var>) > 0,
9780
+ then <var>Avg</var>(<var>S</var>) =
9781
+ <var><a href="#defn_aggSum">Sum</a></var>(<var>S</var>) /
9782
+ <var><a href="#defn_aggCount">Count</a></var>(<var>S</var>).</p>
9783
+ </div>
9784
+ <p>For example, <var>Avg</var>([(1), (2), (3)]) =
9785
+ <var>Sum</var>([(1), (2), (3)])/<var>Count</var>([(1), (2), (3)])
9786
+ = 6/3 = 2.</p>
9781
9787
</section>
9782
9788
<section id="aggMin">
9783
9789
<h5>Min</h5>
@@ -9789,7 +9795,8 @@ <h5>Min</h5>
9789
9795
<p><b>Definition: <span id="defn_aggMin">Min</span></b></p>
9790
9796
<pre class="code nohighlight">term <var>Min</var>(sequence <var>S</var>)</pre>
9791
9797
<p><var>Min</var>(<var>S</var>) = <var>MinList</var>(<var>L</var>),</p>
9792
- <p>where <var>L</var> is the list of values obtained by Flatten(<var>S</var>)
9798
+ <p>where <var>L</var> is the list of values obtained by
9799
+ <a href="#defn_Flatten">Flatten</a>(<var>S</var>)
9793
9800
and then ordered as per the <code>ORDER BY ASC</code> clause,
9794
9801
and <var>MinList</var>(<var>L</var>) is defined as follows.</p>
9795
9802
<ul>
@@ -9812,7 +9819,8 @@ <h5>Max</h5>
9812
9819
<p><b>Definition: <span id="defn_aggMax">Max</span></b></p>
9813
9820
<pre class="code nohighlight">term <var>Max</var>(sequence <var>S</var>)</pre>
9814
9821
<p><var>Max</var>(<var>S</var>) = <var>MaxList</var>(<var>L</var>),</p>
9815
- <p>where <var>L</var> is the list of values obtained by Flatten(<var>S</var>)
9822
+ <p>where <var>L</var> is the list of values obtained by
9823
+ <a href="#defn_Flatten">Flatten</a>(<var>S</var>)
9816
9824
and then ordered as per the <code>ORDER BY DESC</code> clause,
9817
9825
and <var>MaxList</var>(<var>L</var>) is defined as follows.</p>
9818
9826
<ul>
@@ -9845,8 +9853,8 @@ <h5>GroupConcat</h5>
9845
9853
</ul>
9846
9854
<p><var>GroupConcat</var>(<var>S</var>, <var>scalarvals</var>) =
9847
9855
<var>GCList</var>(<var>L</var>, <var>sep</var>),</p>
9848
- <p>where <var>L</var> = Flatten(<var>S</var>) and
9849
- <var>GCList</var>(<var>L</var>, <var>sep</var>)
9856
+ <p>where <var>L</var> = <a href="#defn_Flatten"> Flatten</a> (<var>S</var>)
9857
+ and <var>GCList</var>(<var>L</var>, <var>sep</var>)
9850
9858
is defined recursively as follows.</p>
9851
9859
<ul>
9852
9860
<li>If <a href="#defn_Card">Card</a>(<var>L</var>) = 0, then
@@ -9872,12 +9880,15 @@ <h5>Sample</h5>
9872
9880
to it.</p>
9873
9881
<div class="defn">
9874
9882
<p><b>Definition: <span id="defn_aggSample">Sample</span></b></p>
9875
- <pre class="code nohighlight">RDFTerm Sample(sequence S)</pre>
9876
- <p>Sample(S) = v, where v in Flatten(S)</p>
9877
- <p>Sample([]) = error</p>
9878
- </div>
9879
- <p>For example, given Sample([("a"), ("b"), ("c")]), "a", "b", and "c" are all valid return
9880
- values. Note that Sample() is not required to be deterministic for a given input, the
9883
+ <pre class="code nohighlight">RDFTerm <var>Sample</var>(sequence <var>S</var>)</pre>
9884
+ <p>If <a href="#defn_Card">Card</a>(<var>S</var>) = 0, then
9885
+ <var>Sample</var>(<var>S</var>) = error.</p>
9886
+ <p>If <a href="#defn_Card">Card</a>(<var>S</var>) > 0, then
9887
+ <var>Sample</var>(<var>S</var>) = <var>v</var>, where <var>v</var>
9888
+ in <a href="#defn_Flatten">Flatten</a>(<var>S</var>).</p>
9889
+ </div>
9890
+ <p>For example, given <var>Sample</var>([("a"), ("b"), ("c")]), "a", "b", and "c" are all valid return
9891
+ values. Note that the <var>Sample</var> function is not required to be deterministic for a given input. The
9881
9892
only restriction is that the output value must be present in the input sequence.</p>
9882
9893
</section>
9883
9894
</section>
0 commit comments