title: SQL - Informix error leads to another error - hallway of mirrors P.I.T.A
body: <p>I'm using Informix version 11.50.FC6 via iSql<hr></p>
  
  <p>I'm giving the result of a <code>CASE</code> block a virtual name, <code>att_hrs</code></p>
  
  <pre><code>SELECT      c.id,
              CASE    WHEN    (   c.prog = 'UNDG'
                                  AND (c.grd  IN (SELECT DISTINCT grd FROM grd_table WHERE att_fctr = 1) OR (c.grd IN ('TR','W','LAB','WC')))
                                  AND c.grd   NOT IN ('WM')
                                  AND c.stat  NOT IN ('X','D'))
                      THEN    CAST(SUM(c.hrs) AS CHAR(4))
                      ELSE    'ELSED (att)'
              END     att_hrs 
  FROM        cw_rec c
  WHERE       c.id IN (SELECT DISTINCT id FROM stu_ids)
  GROUP BY    c.id
  INTO TEMP   cheese
  WITH NO LOG;
  </code></pre>
  
  <p>This gives me an error:</p>
  
  <pre><code>294: The column (att_hrs) must be in the GROUP BY list.
  </code></pre>
  
  <p>Trying to fix the error as suggested:</p>
  
  <pre><code>SELECT      c.id,
              CASE    WHEN    (   c.prog = 'UNDG'
                                  AND (c.grd  IN (SELECT DISTINCT grd FROM grd_table WHERE att_fctr = 1) OR (c.grd IN ('TR','W','LAB','WC')))
                                  AND c.grd   NOT IN ('WM')
                                  AND c.stat  NOT IN ('X','D'))
                      THEN    CAST(SUM(c.hrs) AS CHAR(4))
                      ELSE    'ELSED (att)'
              END     att_hrs 
  FROM        cw_rec c
  WHERE       c.id IN (SELECT DISTINCT id FROM stu_ids)
  GROUP BY    c.id,
              att_hrs
  INTO TEMP   cheese
  WITH NO LOG;
  </code></pre>
  
  <p>Then gives me this error:</p>
  
  <pre><code>217: Column (att_hrs) not found in any table in the query (or SLV is undefined).
  </code></pre>
  
  <hr>
  
  <p>They kind of found <code>att_hrs</code> pretty easily when it wasn't in the <code>GROUP BY</code> party, but now all of a sudden, <code>att_hrs</code> is lost in the sauce...</p>
  
  <p>Can you get around this?  </p>
  
  <p>What are the real errors &amp;| solutions to what is going on here and what I need to do to fix it?
  <hr><b>EDIT</b><br>
  I tried RET's solution to <code>GROUP BY 1,2,3...</code> and got the following error:</p>
  
  <p><code>321: Cannot group by aggregate column.</code></p>