Skip to content

Commit 580f1f7

Browse files
authored
Merge pull request #127 from w3c/FollowUpToPR124
Improves the definitions of Count, Avg, and Sample
2 parents 092d14f + 0c735c0 commit 580f1f7

File tree

1 file changed

+31
-20
lines changed

1 file changed

+31
-20
lines changed

spec/index.html

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9732,10 +9732,10 @@ <h5>Count</h5>
97329732
has a bound, non-error value within the aggregate group.</p>
97339733
<div class="defn">
97349734
<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>
97399739
</div>
97409740
</section>
97419741
<section id="aggSum">
@@ -9749,7 +9749,7 @@ <h5>Sum</h5>
97499749
<p><b>Definition: <span id="defn_aggSum">Sum</span></b></p>
97509750
<pre class="code nohighlight">numeric <var>Sum</var>(sequence <var>S</var>)</pre>
97519751
<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
97539753
<var>SumList</var>(<var>L</var>) is defined recursively as follows.</p>
97549754
<ul>
97559755
<li>If <a href="#defn_Card">Card</a>(<var>L</var>) = 0, then
@@ -9773,11 +9773,17 @@ <h5>Avg</h5>
97739773
average value for an expression over a group. It is defined in terms of Sum and Count.
97749774
<div class="defn">
97759775
<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) &gt; 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>) &gt; 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>
97819787
</section>
97829788
<section id="aggMin">
97839789
<h5>Min</h5>
@@ -9789,7 +9795,8 @@ <h5>Min</h5>
97899795
<p><b>Definition: <span id="defn_aggMin">Min</span></b></p>
97909796
<pre class="code nohighlight">term <var>Min</var>(sequence <var>S</var>)</pre>
97919797
<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>)
97939800
and then ordered as per the <code>ORDER BY ASC</code> clause,
97949801
and <var>MinList</var>(<var>L</var>) is defined as follows.</p>
97959802
<ul>
@@ -9812,7 +9819,8 @@ <h5>Max</h5>
98129819
<p><b>Definition: <span id="defn_aggMax">Max</span></b></p>
98139820
<pre class="code nohighlight">term <var>Max</var>(sequence <var>S</var>)</pre>
98149821
<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>)
98169824
and then ordered as per the <code>ORDER BY DESC</code> clause,
98179825
and <var>MaxList</var>(<var>L</var>) is defined as follows.</p>
98189826
<ul>
@@ -9845,8 +9853,8 @@ <h5>GroupConcat</h5>
98459853
</ul>
98469854
<p><var>GroupConcat</var>(<var>S</var>, <var>scalarvals</var>) =
98479855
<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>)
98509858
is defined recursively as follows.</p>
98519859
<ul>
98529860
<li>If <a href="#defn_Card">Card</a>(<var>L</var>) = 0, then
@@ -9872,12 +9880,15 @@ <h5>Sample</h5>
98729880
to it.</p>
98739881
<div class="defn">
98749882
<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>) &gt; 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
98819892
only restriction is that the output value must be present in the input sequence.</p>
98829893
</section>
98839894
</section>

0 commit comments

Comments
 (0)