title: Teradata error "Selected non-aggregate values must be part of the associated group"
body: <pre><code>&gt;SELECT sku, jun_sale, jul_sale, aug_sale, (jun_sale + jul_sale + aug_sale) 
  &gt;AS total_sale,
  &gt;CASE 
  &gt;when EXTRACT(MONTH from saledate)=6 AND stype= 'P'
  &gt;then sum(amt)
  &gt;end as jun_sale,
  &gt;CASE
  &gt;when EXTRACT(MONTH from saledate)=7 AND stype= 'P'
  &gt;then sum(amt)
  &gt;end as jul_sale,
  &gt;CASE
  &gt;when EXTRACT(MONTH from saledate)=8 AND stype= 'P'
  &gt;then sum(amt)
  &gt;end as aug_sale
  &gt;FROM trnsact
  &gt;group by 1
  &gt;order by total_sale;
  </code></pre>
  
  <blockquote>
    <p>Selected non-aggregate values must be part of the associated group</p>
  </blockquote>
  
  <p>Can someone find out what is the error in the case?</p>