title: Counting the number of distinct values of a column
body: <p>I'm running the following query with the following output....</p>
  
  <pre><code>   SELECT g.id,
          g.ticket,
          g.fac_id,
          Cast(g.dts AS DATE) AS dt,
          Count(DISTINCT Cast(g.dts AS DATE)) AS days_used
      FROM db1.table1 g
      INNER JOIN db2.table2 f
          ON f.fac_id = g.fac_id
          AND g.ticket = '07100103031500002'       
          AND f.loc IN (80007944, 80007838, 80007998, 80007823)
      GROUP BY g.id, g.ticket, g.fac_id, Cast(g.strt_dts AS DATE)
  
  id  ticket  fac_id  dt  days_used
  FB3CDE6B2FBE42BEA2BAD79CACA70055    07100103031500002   80,007,944  1/2/2016    1
  FB3CDE6B2FBE42BEA2BAD79CACA70055    07100103031500002   80,007,823  1/3/2016    1
  FB3CDE6B2FBE42BEA2BAD79CACA70055    07100103031500002   80,007,944  7/22/2018   1
  FB3CDE6B2FBE42BEA2BAD79CACA70055    07100103031500002   80,007,998  1/2/2016    1
  FB3CDE6B2FBE42BEA2BAD79CACA70055    07100103031500002   80,007,838  1/4/2016    1
  FB3CDE6B2FBE42BEA2BAD79CACA70055    07100103031500002   80,007,944  1/3/2016    1
  </code></pre>
  
  <p>I'm trying to get the days_used column to count the distinct values in the dt column, so my days_used column should all be 4 instead of 1. Any help in changing the code? I'm hoping to just change the select structure for deriving days_used if possible.</p>