Richard Hipp wrote:
> So if you say "group_concat(DISTINCT x,y)" does that mean that the
> combination of x and y must be distinct or that only x is distinct?
> Are we allowed to say "group_concat(x, DISTINCT y)" or
> "group_concat(DISTINCT x, DISTINCT y)".  And what does the latter
> mean, exactly?
>
> Are there any other SQL database engines that allow multi-argument
> aggregate functions?  What do those systems do?

PostgreSQL says 
<http://www.postgresql.org/docs/9.4/static/sql-expressions.html#SYNTAX-AGGREGATES>:
| aggregate_name (expression [ , ... ] [ order_by_clause ] )
| aggregate_name (ALL expression [ , ... ] [ order_by_clause ] )
| aggregate_name (DISTINCT expression [ , ... ] [ order_by_clause ] )
|
| The first form of aggregate expression invokes the aggregate once for
| each input row. The second form is the same as the first, since ALL is
| the default. The third form invokes the aggregate once for each
| distinct value of the expression (or distinct set of values, for
| multiple expressions) found in the input rows.

Testing <http://www.sqlfiddle.com/#!12/ddd8e/1> shows that the DISTINCT
applies to the function, not to individual parameters, and that indeed
the set of all parameters is checked:

  CREATE TABLE test (
    value VARCHAR(10),
    delim VARCHAR(1)
  );
  INSERT INTO test VALUES ('a', ',');
  INSERT INTO test VALUES ('b', ';');
  INSERT INTO test VALUES ('c', '/');
  INSERT INTO test VALUES ('c', '/');
  INSERT INTO test VALUES ('c', ':');
  INSERT INTO test VALUES ('d', ',');

  SELECT string_agg(DISTINCT value, delim) FROM test;

=>

  a;b:c/c,d


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to