title: How to calculate the percentage of total in Spark SQL
body: <p>Considering the following data:</p>
  
  <pre><code>Name | Flag
  A    | 0
  A    | 1
  A    | 0
  B    | 0
  B    | 1
  B    | 1
  </code></pre>
  
  <p>I'd like to transform it to:</p>
  
  <pre><code>Name | Total | With Flag | Percentage
  A    | 3     | 1         | 33%
  B    | 3     | 2         | 66%
  </code></pre>
  
  <p>Preferably, in Spark SQL.</p>