title: Warning: Null value is eliminated by an aggregate or other SET operation
body: <p>I'm running the following script - </p>
  
  <pre><code>declare @eventname VARCHAR(64)
  declare @eventid INT
  
  set @eventname = 'event123'
  set @eventid = (select tm.trgmst_id from trgmst tm where tm.trgmst_name = @eventname)
  
  declare @trgjobmax INT
  set @trgjobmax = (select max(trgjob_id) from trgjob)
  
  declare @jobid TABLE (jobmst_id INT, trgjob_order INT)
  
  insert into @jobid (jobmst_id, trgjob_order)
     select 
         jm.jobmst_id, max(tj.trgjob_order) 
     from 
         jobmst jm
     left outer join 
         trgjob tj on tj.jobmst_id = jm.jobmst_id
     inner join 
         workgrp wg on wg.workgrp_id = jm.jobmst_owner
     where 
         wg.workgrp_name in ('group1', 'group2', 'group3')
         and jm.jobmst_type = 2 
         and jm.jobmst_dirty &lt;&gt; 'X' 
         and jm.jobmst_id NOT IN (select tj.jobmst_id 
                                  from trgjob tj
                                  where tj.trgmst_id = @eventid)
     group by 
         jm.jobmst_id
     order by 
         jm.jobmst_id desc
  </code></pre>
  
  <p>The problem is I get this message - </p>
  
  <blockquote>
    <p>Warning: Null value is eliminated by an aggregate or other SET
    operation.</p>
  </blockquote>
  
  <p>The reason is that it is not always guaranteed to have a trgjob_order value so it displays as NULL.  I then have to run the following update script in the same transaction and it seems to work fine.</p>
  
  <pre><code>update @jobid
  set trgjob_order = 0
  where trgjob_order IS NULL
  </code></pre>
  
  <p>Is there a way to write this more elegantly?  The data I'm given looks correct so I'm taking the warning as just that... It's a warning but can be ignored because I'm doing an update POST to replace the NULL with 0.</p>