title: "Divide by zero error" error after join in sql server (that doesn't add any rows)
body: <p>First time asking a question here, I apologize if I make any mistakes.</p>
  
  <p>Here's the thing, I have the following query that works just fine:</p>
  
  <pre><code>select *
  , [ENERGIA_NETA_SMEC_MWH]*  [CONSUMO_DE_GAS_DAM3] * 9300 * 1000  / ( [CONSUMO_DE_GAS_DAM3] *9300 * 1000 + [CONSUMO_DE_GASOIL_M3] * 9211 +  [CONSUMO_DE_FUELOIL_T] * 10500 *1000 ) as 'Energia generada GN MWh '
  from tabla_parte tp
  </code></pre>
  
  <p>The issue "Divide by zero error encountered." appears when I add a left join:</p>
  
  <pre><code>select *
  , [ENERGIA_NETA_SMEC_MWH]*  [CONSUMO_DE_GAS_DAM3] * 9300 * 1000  / ( [CONSUMO_DE_GAS_DAM3] *9300 * 1000 + [CONSUMO_DE_GASOIL_M3] * 9211 +  [CONSUMO_DE_FUELOIL_T] * 10500 *1000 ) as 'Energia generada GN MWh '
  from tabla_parte tp
  left join cog.dbo.ParteDetalle pd
  on tp.ParteID = pd.ParteID and pd.ItemID = 46
  </code></pre>
  
  <p>I can't seems to find out why the error appears, since the left join shouldn't add any rows. I've verified with with the following queries:</p>
  
  <pre><code>select count(1) from tabla_parte tp
  
  select count(1) from tabla_parte tp
  left join cog.dbo.ParteDetalle pd
  on tp.ParteID = pd.ParteID and pd.ItemID = 46
  </code></pre>
  
  <p>Both of them give me the same number.</p>
  
  <p>Since the left join isn't adding any rows, why does the error appear after the join?</p>
  
  <p>Thanks!</p>