@@ -303,22 +303,22 @@ Let us apply these steps to the ``sum`` aggregate in the following query:
303
303
.. code-block :: ql
304
304
305
305
select sum(int i, int j |
306
- exists(string char | char = "hello".charAt(i)) and exists(string char | char = "world!".charAt(j)) | i)
306
+ exists(string s | s = "hello".charAt(i)) and exists(string s | s = "world!".charAt(j)) | i)
307
307
308
308
#. Input variables: ``i ``, ``j ``.
309
309
310
310
#. All possible tuples ``(<value of i>, <value of j>) `` satisfying the given condition:
311
- ``(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 0), (1, 1),...,(4, 5) ``.
311
+ ``(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 0), (1, 1), ..., (4, 5) ``.
312
312
313
- `` 30 `` tuples are generated in this step.
313
+ 30 tuples are generated in this step.
314
314
315
315
#. Apply the ``<expression> i `` on all tuples. This means selecting all values of ``i `` from
316
316
all tuples: ``0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4. ``
317
317
318
318
#. Apply the aggregation function ``sum `` on the above values to get the final result ``60 ``.
319
319
320
- If we change ``<expression> `` to ``i+ j `` in the above query, the query result is ``135 `` since
321
- applying ``i+ j `` on all tuples results in following values:
320
+ If we change ``<expression> `` to ``i + j `` in the above query, the query result is ``135 `` since
321
+ applying ``i + j `` on all tuples results in following values:
322
322
\ ``0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 7, 3, 4, 5, 6, 7, 8, 4, 5, 6, 7, 8, 9 ``.
323
323
324
324
Next, consider the following query:
@@ -327,11 +327,15 @@ Next, consider the following query:
327
327
328
328
select count(string s | s = "hello" | s.charAt(_))
329
329
330
- ``s `` is the input variable of the aggregate. A single tuple ``("hello") `` is generated after
331
- applying step 2. When the ``<expression> charAt(_) `` is applied on this tuple, it generates ``4 ``
332
- distinct values ``'h', 'e', 'l', 'o' ``. Note that ``'l' `` only appears once as this step collects
333
- the distinct values generated as a result of applying ``<expression> ``. Finally, ``count `` is
334
- applied on these values, and the query returns ``4 ``.
330
+ #. ``s `` is the input variable of the aggregate.
331
+
332
+ #. A single tuple ``"hello" `` is generated in this step.
333
+
334
+ #. The ``<expression> charAt(_) `` is applied on this tuple. The underscore ``_ `` in ``charAt(_) ``
335
+ is a :ref: `don't-care expression <dont-care >`, which represents any value.
336
+ ``s.charAt(_) `` generates four distinct values ``h, e, l, o ``.
337
+
338
+ #. Finally, ``count `` is applied on these values, and the query returns ``4 ``.
335
339
336
340
337
341
0 commit comments