SQL grouping by all the columns

后端 未结 9 1489
囚心锁ツ
囚心锁ツ 2020-12-29 02:04

Is there any way to group by all the columns of a table without specifying the column names? Like:

select * from table group by *
9条回答
  •  隐瞒了意图╮
    2020-12-29 02:20

    nope. are you trying to do some aggregation? if so, you could do something like this to get what you need

    ;with a as
    (
         select sum(IntField) as Total
         from Table
         group by CharField
    )
    select *, a.Total
    from Table t
    inner join a
    on t.Field=a.Field
    

提交回复
热议问题