Help me with a SQL query. I would get all values, like '01,02,03,20,92,93,94" values from first query, but instead of function MAX in two query. Result:in opposite b_BookNum I would to see one string:'01,02,03,20,92,93,94'

Help me with a SQL query. I would get all values, like '01,02,03,20,92,93,94" values from first query, but instead of function MAX in two query. Result:in opposite b_BookNum I would to see one string:'01,02,03,20,92,93,94'

Simply take out the MAX() function and add this column in your group by clause , happy days......
SELECT [b_BookNum]
,[b_CHMAT]
,COUNT(*) iCount
FROM MPA.dbo.SCHM_Books
GROUP BY [b_BookNum] ,[b_CHMAT]
ORDER BY [b_BookNum]
I am surprised that you have all the information you need to solve the problem and yet you are so incompetent to solve it. Anyway here is the full solution:
;WITH CTE AS (
SELECT [b_BookNum]
,COUNT(*) iCount
FROM MPA.dbo.SCHM_Books
GROUP BY [b_BookNum]
)
SELECT [b_BookNum]
,STUFF((SELECT ',' + CAST([b_CHMAT] AS VARCHAR(10))
FROM dbo.SCHM_Books
WHERE [b_BookNum] = C.[b_BookNum]
FOR XML PATH(''),TYPE)
.value('.','NVARCHAR(MAX)'),1,1,'') AS [b_CHMAT]
,iCount
FROM CTE C