title: tsql returns the right answer only when I specify the criteria in the where clause
body: <p>I have some sql that will not return the rows I need unless I specify that as a criteria in the where clause. If I uncomment the part below that is commented out, it will give me the rows I want. If I leave it commented out, those rows are not returned in my result set. </p>
  
  <p>Does this make sense? Can anyone see anything I'm doing wrong? Thanks.</p>
  
  <pre><code>SELECT     
     RTRIM(c.comp2) + '-' + l.Loc_Name, 
     MAX(RTRIM(g.mega_location_num) + '-' + g.mega_location_name) 
  FROM       
     mkt_share_comp c, gldm_location g, mkt_share_locs l 
  WHERE     
     RTRIM(c.comp1) = g.location_num
     AND c.comp2 = l.Loc_No
     AND LEN(c.comp2) = 5 AND c.is_deleted = 0 AND l.is_deleted = 0
     --and  g.mega_location_num = '450'
  GROUP BY
     RTRIM(c.comp2) + '-' + l.Loc_Name
  ORDER BY
     MAX(RTRIM(g.mega_location_num) + '-' + g.mega_location_name) 
  </code></pre>