How do I count the number of elements in each group? <p>How do I get a count of the elements within a particular group? So in the query below I want to know how many cancelled and active subscriptions each account has. What I am getting is either 0 or 1, depending on whether they have at least one cancelled or active subscription.</p> <pre><code>from a in Accounts let subs = ( from s in Subscriptions.Where(s=&gt;s.AccountId == a.Id) group s by s.Status into bystatus select bystatus ) let csubs = subs.Count (s =&gt;s.Key == "Cancelled") let asubs = subs.Count (s =&gt; s.Key == "Active") orderby a.Name select new { a.Name,a.AccountNumber, a.Status, ActiveSubscriptionCount = asubs, CancelledSubscriptionCount = csubs } </code></pre>