Is there any way to group by all the columns of a table without specifying the column names? Like:
select * from table group by *
If you are using SqlServer the distinct keyword should work for you. (Not sure about other databases)
declare @t table (a int , b int)
insert into @t (a,b) select 1, 1
insert into @t (a,b) select 1, 2
insert into @t (a,b) select 1, 1
select distinct * from @t
results in
a b
1 1
1 2
Short answer: no. GROUP BY clauses intrinsically require order to the way they arrange your results. A different order of field groupings would lead to different results.
Specifying a wildcard would leave the statement open to interpretation and unpredictable behaviour.
No because this fundamentally means that you will not be grouping anything. If you group by all columns (and have a properly defined table w/ a unique index) then SELECT * FROM table
is essentially the same thing as SELECT * FROM table GROUP BY *
.