CREATE TABLE [dbo].[theRecords](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [varchar](50) NULL,
[thegroup] [varchar](50) NULL,
[balance] [int] NULL,
)
GO
insert into theRecords values('blue',1,10)
insert into theRecords values('green',1,20)
insert into theRecords values('yellow',2,5)
insert into theRecords values('red',2,4)
insert into theRecords values('white',3,10)
insert into theRecords values('black',4,10)
首先,我想得到每个组的余额总和,然后对于只有一个组的名称,应该保留名称,然后属于同一组的名称也应该更改组名。
name | balance
1 30
2 9
white 10
black 10