create table #FruitTable(IdFruit int identity(1,1), NameFruit varchar(20), Price float)
insert into #FruitTable values('apple',12)
insert into #FruitTable values('orange',15)
insert into #FruitTable values('cherry',17)
select * from #FruitTable
create table #SalesTable(Id int identity(1,1), Name varchar(20), IdFruit varchar(9))
insert into #SalesTable values('Rustam','1,3,')
insert into #SalesTable values('Firuz','2,4,3,')
insert into #SalesTable values('Sadriddin','1,')
select * from #SalesTable
SELECT Id,
name,
REPLACE(SUM(CAST(REPLACE(Price,',','.') AS DECIMAL(18,2))),'.',',') AS Price
FROM
(
select s.Id, s.Name,f.Price from #FruitTable f, #SalesTable s
where f.IdFruit in(SELECT CAST(item AS INTEGER) FROM dbo.SplitString(s.IdFruit, ','))
) as mainPerson
GROUP BY mainPerson.Id, mainPerson.name
drop table #SalesTable
drop table #FruitTable