title: Linq query with GROUP BY on multiple fields, SUM and COUNT
body: <p>I'm trying to use a LINQ SQL to query my database.</p>
  
  <p>Let's say I have some data that looks like this:</p>
  
  <pre><code>var1 var2 var3 qty
  1    a    1a   50
  1    a    1a   25
  2    b    2b   10
  2    b    2b   15
  2    b    2b   10
  3    a    3a   25
  </code></pre>
  
  <p>I know how to format my query in SQL. It would be something like this:</p>
  
  <pre><code>SELECT var1, var2, var3, count(*) AS count, sum(qty) As quantity
      FROM MyTable
      GROUP BY var1, var2, var3
  </code></pre>
  
  <p>In this case the output would be something like this:</p>
  
  <pre><code>var1 var2 var3 Count Qty
  1    a    1a   2     75
  2    b    2b   3     35
  3    a    3a   1     25
  </code></pre>
  
  <p>How can I do the same thing with LINQ in vb.net</p>
  
  <pre><code>Dim groups = From j In MyTable
               Group By j.var1, j.var2, j.var3 Into g
               Select new {var1 = g.var1, 
                           var2 = g.var2, 
                           var3 = g.var3, 
                           quantity = sum(g.qty),
                           count = count(*)}
  </code></pre>
  
  <p>That's not quite right, but I think it's close. I don't understand the syntax of the group by in VB.NET.</p>