title: SQL to LINQ Statement including Group By and Order By
body: <p>I have an SQL query below:</p>
  
  <pre><code>SELECT DISTINCT 
      Table1.Description, 
      Table2.AccountId, 
      COUNT(Table2.AccountId) AS Charges 
  FROM Table2 
  LEFT JOIN Table1 ON Table2.AccountId = Table1.Id 
  WHERE Table2.DateTime &gt; '3/1/2014' 
      AND Table2.DateTime &lt; '4/1/2014' 
  GROUP BY Table2.AccountId, Table1.Description 
  ORDER BY Charges DESC
  </code></pre>
  
  <p>I am trying to convert this to a LINQ query in the ASPX.CS code behind to populate a table and to use the data in a chart.</p>
  
  <p>What I have so far is below:</p>
  
  <pre><code>var resultList = configDB.Table2
      .Where(x =&gt; x.DateTime &gt; begDate &amp;&amp; x.DateTime &lt; endDate)
      .GroupBy(x =&gt; x.AccountID)
      .Select(g =&gt; new { Account = g.Key, Charges = g.Count() })
      .OrderByDescending(g =&gt; g.Charges)
      .ToList(); 
  </code></pre>
  
  <p>This is only the Table 2 portion.  I'm trying to join Table 1 as well and still get the count of Charges which from toying around with the code I was unable to get.  I've found several posts and solutions to do each one individually but not an answer where they are grouping by and joining while getting a count of a column.  Can anyone direct me to a resource that will help or point me in the right direction?</p>