title: Function always returns null even with ISNULL
body: <p>I have the following function:</p>
  
  <pre><code>CREATE FUNCTION HARDCODERS.getKilosDisponiblesViaje(@Viaje int)
  
  RETURNS TABLE
  AS
  RETURN 
  
  (
  select Micro.KG_Disponibles - SUM(Encomienda.Cant_KG) as KGDisponibles
  from HARDCODERS.Micro, HARDCODERS.Viaje, HARDCODERS.Encomienda, HARDCODERS.PasajeEncomienda
  where Viaje.Cod_Viaje = @Viaje AND Viaje.Patente = Micro.Patente AND PasajeEncomienda.Cod_Viaje = @Viaje
      AND PasajeEncomienda.Cod_PasajeEncomienda = Encomienda.Cod_PasajeEncomienda
  group by Micro.KG_Disponibles,Micro.Patente
  )
  
  GO 
  </code></pre>
  
  <p>It works fine if I have rows in Encomienda. However, if I don't the function will always return null.</p>
  
  <p>I added an ISNULL to the SUM, also tried inside of it and it keeps returning null if there are no rows in Encomienda.</p>
  
  <p>Micro.KG_Disponibles always has a value.</p>