title: Error: Invalid expression in the select list (not contained in either an aggregate function or the GROUP BY clause)
body: <p>I am using Firebird SQL. The below mentioned query returns 4 rows as shown in the figure.</p>
  
  <pre><code>    SELECT a.EPS_ID,b.C_NAME,c.AY_YR_NAME,d.S_NAME,e.E_NAME
  FROM 
      TBLEXAMPLANNER_S_MSB a, 
      TBLCLASS_MSB b, 
      TBLACADEMICYEAR_MSB c, 
      TBLSUBJECTS_MSB d, 
      TBLEXAMTYPE_MSB e
  WHERE 
      a.EPS_CLASS_ID=b.C_ID 
  AND a.EPS_SESSION_ID=c.AY_ID 
  AND a.EPS_SUB_ID=d.S_ID 
  AND a.EPS_PE_ID=e.E_ID
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ht3R0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ht3R0.png" alt="click to view image"></a></p>
  
  <p>I want it to return only 1(one) row like</p>
  
  <pre><code>EPS_ID     C_NAME    AY_YR_NAME   S_NAME   E_NAME
  ---------------------------------------------------
  7          5         2016-2017    English  FA1 
  </code></pre>
  
  <p>I am using the following query but it does not work.</p>
  
  <pre><code>SELECT a.EPS_ID,MAX(b.C_NAME) AS XT,c.AY_YR_NAME,d.S_NAME,e.E_NAME
  FROM 
      TBLEXAMPLANNER_S_MSB a, 
      TBLCLASS_MSB b, 
      TBLACADEMICYEAR_MSB c, 
      TBLSUBJECTS_MSB d, 
      TBLEXAMTYPE_MSB e
  WHERE 
      a.EPS_CLASS_ID=b.C_ID 
  AND a.EPS_SESSION_ID=c.AY_ID 
  AND a.EPS_SUB_ID=d.S_ID 
  AND a.EPS_PE_ID=e.E_ID
  GROUP BY a.EPS_ID,d.S_NAME
  </code></pre>
  
  <p>The error message is :</p>
  
  <blockquote>
    <p>Invalid expression in the select list (not contained in either an
    aggregate function or the GROUP BY clause)</p>
  </blockquote>