Add boolean aggregate functions EVERY, ANY and SOME
---------------------------------------------------

                 Key: CORE-5975
                 URL: http://tracker.firebirdsql.org/browse/CORE-5975
             Project: Firebird Core
          Issue Type: New Feature
          Components: Engine
            Reporter: Mark Rotteveel


The SQL standard defines the boolean aggregate functions EVERY, ANY and SOME 
(see SQL:2016-2 10.9 <aggregate function>). In a way, these are the counterpart 
of the quantified comparison predicates (ALL, ANY and SOME) that Firebird 
already supports.

The value expression inside the aggregate is a boolean expression, eg

EVERY(somebooleancolumn) is true if all values for somebooleancolumn are true 
(also true if the group set is empty, which can be relevant when also using a 
FILTER-clause).
ANY(x = 'y' and someothercolumn is null) is true if at least one row in the 
group set has a column x with value 'y' and someothercolumn null.

From the standard:

"""
Syntax Rules
[..]
7) If <general set function> is specified, then:
[..]
  b) Let DT be the declared type of the <value expression>.
[..]
  e) If EVERY, ANY, or SOME is specified, then DT shall be boolean and the 
declared type of the result is boolean.

[..]
General Rules
[..]
7) If <general set function> is specified, then:
  a) Let TX be the single-column table that is the result of applying the 
<value expression> to each row of T1 and eliminating null values. If one or 
more null values are eliminated, then a completion condition is raised: warning 
— null value eliminated in set function.
  b) Case:
    i) If DISTINCT is specified, then let TXA be the result of eliminating 
redundant duplicate values from TX, using the comparison rules specified in 
Subclause 8.2, "<comparison predicate>", to identify the redundant duplicate 
values.
    ii) Otherwise, let TXA be TX.
[..]
  d) Case:
[..]
  vi) If EVERY is specified, then
  Case:
    1) If the value of some element of TXA is False, then the result is False.
    2) Otherwise, the result is True.
  vii) If ANY or SOME is specified, then
  Case:
    1) If the value of some element of TXA is True, then the result is True.
    2) Otherwise, the result is False.
"""

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to