title: Trying to count number of complaint, cause, corrections
body: <p>I am trying to create a query with the following fields, that counts the number of Complaints, causes, and corrections show up in the data.</p>
  
  <p>My current error:  Select non-aggregate values must be part of the associated group.  </p>
  
  <p>I am very new to SQL queries, and am not sure what else I'm missing. All I've done is merged to queries, and seem to be missing something.</p>
  
  <pre><code>select L.Case_ID,
      L.Case_Line_ID,
      A.Dealer_ID,
      M.DealerCode,
      H.DealerName,
      substr(L.Estimate_Created_At,1,7) as CaseMonth,
      count(distinct L.Complaint) as Complaint,                 
      count(distinct C.Cause) as Cause,
      count(distinct C.Correction) as Correction
  from     Decisiv_Tables_Prod.Stg_Decisiv_LineItems L
  join     Decisiv_Tables_Prod.Stg_Decisiv_Cases A on L.Case_ID = A.Case_ID
  join      Decisiv_Tables_Prod.Rpt_DecisivDealerMap M on A.Dealer_ID = M.DecisivDealerID
  and cast(substr(L.Estimate_Created_At,1,10) as date format 'YYYY-MM-DD') between                                                                 M.EffectiveStartDate and coalesce(M.EffectiveEndDate, cast('2099-12-31' as date format 'YYYY-MM-DD'))
  join Decisiv_Tables_Prod.Rpt_DealerDirectoryHierarchy H on  M.DealerCode = H.DealerCode                                                              
  join Decisiv_Tables_Prod.Stg_Decisiv_LineItems_Clobs C on  C.Case_ID = L.Case_ID
  and C.Case_Line_ID = L.Case_Line_ID
  group by 1,2,3,4,5
  </code></pre>
  
  <p>Looking to get a table with the following data example:</p>
  
  <p>Dealer ID, Dealer Code, Dealer Name, Case Month, Count of Case_ID, Count of Case_Line_ID, Count of Complaint, Count of Cause, Count of Correction</p>