Is there a way to group by all columns in a subtable without enumerating them all? e.g. Suppose I wanted to query something like:
SELECT t1.col_1, t1.col_2, ... , t1.col_n, t2.col_k, COUNT(*)
FROM t1, t2
WHERE t2.col1>0
AND t2.col1=t1.col1
GROUP BY t1.col_1, t1.col_2, ... , t1.col_n, t2.col_k
Writing out all these column names (moreover twice) is verbose if n
is large. I am wondering if there is a standard language construct to do this. E.g. a key word COLUMNS
used like:
SELECT COLUMNS(t1), t2.col_k, COUNT(*)
FROM ...
...
GROUP BY COLUMNS(t1), t2.col_k
(Tag included for Postgres as I am interested in a Postgres solution if no SQL standard exists.)