title: SQL Server... Union all on two IF conditions
body: <p>i have two table valued function wich i need to do some selects...
  I was trying to do UNION on that selects but i can't do "union all" to my IF...
  It should return one row and two columns each if condition...
  This code should return :</p>
  
  <pre><code>September | 50
  
  October   | 33
  </code></pre>
  
  <p>how can i do this ?!</p>
  
  <p>this was my code : </p>
  
  <pre><code>IF (select TotalTreinos from dbo.tbl_CALCULA_TREINOS_MES('20160901','20160930',2,5)) = (SELECT Presencas FROM DBO.tbl_CALCULA_PRESENCAS('Setembro',9,2)) 
      SELECT 'Setembro' as Mes, 100 AS PercentPresencas
  else
      select 'Setembro' as Mes, (((SELECT Presencas FROM DBO.tbl_CALCULA_PRESENCAS('Setembro',9,2)) * 100) / (select TotalTreinos from dbo.tbl_CALCULA_TREINOS_MES('20160901','20160930',2,5))) as PercentPresencas
  
  union all
  
  IF (select TotalTreinos from dbo.tbl_CALCULA_TREINOS_MES('20161001','20161031',2,5)) = (SELECT Presencas FROM DBO.tbl_CALCULA_PRESENCAS('Outubro',10,2)) 
      SELECT 'Outubro' as Mes, 100 AS PercentPresencas
  else
      select 'Outubro' as Mes,(((SELECT Presencas FROM DBO.tbl_CALCULA_PRESENCAS('Outubro',10,2)) * 100) / (select TotalTreinos from dbo.tbl_CALCULA_TREINOS_MES('20161001','20161031',2,5))) as PercentPresencas
  </code></pre>