Ok, something like this. I'll need a bit of info to be sure though
Is Queued a bit? That makes a difference in linq where it doesn't in SQL.
I also don't know your context names but you should get the idea.
var query = Context.ExportQueues.Select(x => new {
QueueItem = x.QueueItem,
Sent = !x.Queued ? 1 : 0,
Queued = x.Queued ? 1 : 0,
Exported = x.Success ? 1 : 0,
Failed = !x.Success ? 1 : 0 })
.GroupBy(x => x.QueueItem)
.Select(g => new {
QueueItem = g.Key,
Sent = g.Sum(x => x.Sent),
Queued = g.Sum(x => x.Queued),
Exported = g.Sum(x => x.Exported),
Failed = g.Sum(x => x.Failed)
}).ToList();
EDIT You could also combine these by doing the case on the fly in the query. I always tend to write it out as above first as I work through it though as more complex aggregates can be a bit hard to debug if there's errors:
var query = Context.ExportQueues
.GroupBy(x => x.QueueItem)
.Select(g => new {
QueueItem = g.Key,
Sent = g.Sum(x => !x.Queued ? 1 : 0),
Queued = g.Sum(x => x.Queued ? 1 : 0),
Exported = g.Sum(x => x.Success ? 1 : 0),
Failed = g.Sum(x => !x.Success ? 1 : 0 )
}).ToList();