GROUP BY
In addition to the GROUP BY syntax in a SELECT statement, PSQL supports an extended GROUP BY syntax that can include vendor strings.
A GROUP BY query returns a result set which contains one row of the select list for every group encountered. (See
SELECT for the syntax of a select list.)
The following example shows an extended GROUP BY that includes vendor strings in an escape sequence.
create table at1 (col1 integer, col2 char(10));
insert into at1 values (1, 'abc');
insert into at1 values (2, 'def');
insert into at1 values (3, 'aaa');
SELECT (--(*vendor(Microsoft), product(ODBC) fn left(at1.col2, 1) *)--) atv, count(*) Total FROM at1
GROUP BY atv
ORDER BY atv DESC
Returns:
atv Total
====== ===========
d 1
a 2
See Also