I’ve a data table like
Date status recno
---------------------------------
2012 DST;Par 1
------------------------------------
2012 DST 2
--------------------------------
2012 DST 3
--------------------------------------------
2012 DST;Ts 4
-----------------------------------
Currently I have written a query like this:
var data = from b in table.AsEnumerable()
where b.DateInterval>=fromDate && b.DateInterval<=toDate
group b by b.Channel1_status into g
select new
{
AccountNo=accountNumber,
Status = statusLabels[g.Key].ToString(),
StatusCount = g.Count(),
};
However, it’s returning me results these results:
Result: DST-2
DST;par-1 and DST;Ts-1
Expected: DST-4 DST;par-1 and DST;Ts-1
Please explain to me what I’m doing wrong and how to get the expected results.
If you want to count all with a status starting with DST and still group the variations (DST;par, DST;ts), you could do it manually.
Something like this (not tested, but i think you get the idea):