title: TSQL Pivot with group by
body: <p>I’m using the PIVOT clause to convert this data:</p>
  
  <pre><code>ComponenteID Descripcion                              PosicionID  Email                                                        Nivel
  ------------ ---------------------------------------- ----------- ------------------------------------------------------------ -----
  9            Maquinaria                               19          monica.rodriguez@definity.com                           1
  9            Maquinaria                               19          monica.rodriguez@definity.com                           2
  9            Maquinaria                               19          monica.rodriguez@definity.com                           3
  9            Maquinaria                               150         fulano.detal@definityfirst.com                               1
  </code></pre>
  
  <p>To:</p>
  
  <pre><code>TipoComponenteId Descripcion                              AprobadoresNivel1                                                                   AprobadoresNivel2                                                                   AprobadoresNivel3
  ---------------- ---------------------------------------- ----------------------------------------------------------------------------------- ----------------------------------------------------------------------------------- -----------------------------------------------------------------------------------
  9                Maquinaria                               19 - monica.rodriguez@definity.com, 150 - fulano.detal@definity.com                                             19 - monica.rodriguez@definity.com                                             19 - monica.rodriguez@definity.com
  </code></pre>
  
  <p>But because the MAX clause off course is just showing one element in AprobadoresNivel1 (third column) (see below)</p>
  
  <pre><code>TipoComponenteId Descripcion                              AprobadoresNivel1                                                                   AprobadoresNivel2                                                                   AprobadoresNivel3
  ---------------- ---------------------------------------- ----------------------------------------------------------------------------------- ----------------------------------------------------------------------------------- -----------------------------------------------------------------------------------
  9                Maquinaria                               19 - monica.rodriguez@definityfirst.com                                             19 - monica.rodriguez@definityfirst.com                                             19 - monica.rodriguez@definityfirst.com
  </code></pre>
  
  <p>Is there a way to use a group by in the PIVOT clause? is there other way to accomplish this?</p>