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
看來這是一個爲我而設的問題! –
這些圖像沒有用處,它們只是重複你在'insert'語句中顯示的內容。你能不能展示你想要輸出的樣子?我無法通過更改名稱來弄清楚你的意思。 – Barmar
_對於只有一個group_的名稱 - 您的所有名稱都是唯一的,因此它們都只有一個組。 – Barmar