У меня есть таблица, как этотSQL Server Group By с групповым Concat
Hospital Insurance PatientCount
H1 I1 1
H1 I1 2
H2 I1 1
H2 I2 1
Хочет группу этой таблицу страхования как,
Hospital Insurance PatientCount
H1,H2 I1 4
H2 I2 1
Пробовал с помощью
select
stuff((select ', ' + Hospital
from Insurances
where (InsuranceName = i.InsuranceName)
for xml path(''),type).value('(./text())[1]','varchar(max)')
,1,2,'') as Hospitals,
i.InsuranceName,
sum(i.PatientsCount)
from Insurances i
group by i.InsuranceName;
Выхода:
Hospital Insurance PatientCount
H1,H1,H2 I1 4
H2 I2 1
какая ошибка у вас есть? – tharif
запрос работает нормально, ожидайте, что я хочу отличную больницу –
напишите свой желаемый результат ниже вашего вывода – tharif