Query on multiple fields with a concatenate string field

Let us summarize our understanding:

group the data by Library (maybe other additional keys) and retrieve:
group count = No,
Books count for the different Cities of a group

So we can prototype it with a LINQ to following (some col names simplified)
grafik

Flow:

LINQ:

(From d In dtData.AsEnumerable
Group d By k=d("LIB").toString.Trim Into grp=Group
Let cnt = grp.Count
Let dctDet = grp.GroupBy(Function (g1) g1("City").toString.Trim).ToDictionary(Function (lk) lk.Key, Function (lk) lk.count)
Let strDet = String.Join(",", dctDet.Select(Function (kvp) String.Format("#{0} {1}", kvp.Value.ToString, kvp.Key)))
Let ra = grp.First.ItemArray.Take(3).Concat({cnt, strDet}).ToArray
Select r = dtResult.Rows.Add(ra)).CopyToDataTable

Dont fear the LINQ as we can take it also and decompose it into a NON-LINQ implementation.

Also have a look here: