title: How to calculate sum and count in a single groupBy?
body: <p>Based on the following <code>DataFrame</code>:</p>
  
  <pre><code>val client = Seq((1,"A",10),(2,"A",5),(3,"B",56)).toDF("ID","Categ","Amnt")
  +---+-----+----+
  | ID|Categ|Amnt|
  +---+-----+----+
  |  1|    A|  10|
  |  2|    A|   5|
  |  3|    B|  56|
  +---+-----+----+
  </code></pre>
  
  <p>I would like to to obtain the number of ID and the total amount by category:</p>
  
  <pre><code>+-----+-----+---------+
  |Categ|count|sum(Amnt)|
  +-----+-----+---------+
  |    B|    1|       56|
  |    A|    2|       15|
  +-----+-----+---------+
  </code></pre>
  
  <p>Is it possible to do the count and the sum without having to do a join?</p>
  
  <pre><code>client.groupBy("Categ").count
        .join(client.withColumnRenamed("Categ","cat")
             .groupBy("cat")
             .sum("Amnt"), 'Categ === 'cat)
        .drop("cat")
  </code></pre>
  
  <p>Maybe something like that:</p>
  
  <pre><code>client.createOrReplaceTempView("client")
  spark.sql("SELECT Categ count(Categ) sum(Amnt) FROM client GROUP BY Categ").show()
  </code></pre>