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
_for에는 하나의 그룹 만있는 _ - 모든 이름은 고유하므로 모든 그룹이 하나만 있습니다. – Barmar