title: Snowflake/SQL Accounting for Null Values in Count/Group Output
body: <p>No real idea here how to go about this but I am taking two tables that I have joined on a common user ID and I need to calculate the average count of &quot;tickets&quot; per User ID for all users taking into account users with null tickets submitted.</p>
  <pre><code>SELECT u.UID, u.DATE_CREATED, COUNT(distinct t.tickets) AS COUNT
  FROM users u, tickets t
  
  WHERE u.USER_ID = t.USER_ID
  GROUP BY UID, DATE_CREATED
  ORDER BY COUNT DESC
  </code></pre>
  <p><em><strong>Note</strong> table user has user id info and is joined with tickets table that has ticket ID</em></p>
  <p>There are initially 200 records of user IDs but after running this query, it returns 170 users and the count of tickets submitted like shown below. I believe that the missing 30 users have a null value when counting the tickets.</p>
  <p>[QUESTION] Is it possible to group the null values as '0' and output the associated User ID and 0 value as COUNT to the below example output?</p>
  <p>Current Output:</p>
  <pre><code>UID   COUNT
  252    1291
  251    1222
  250    1000
  [..]   [...]
  212     1
  128     1
  121     1
  </code></pre>
  <p>Desired Output (Counting UID's where Count is Null)
  Current Output:</p>
  <pre><code>UID   COUNT
  252    1291
  251    1222
  250    1000
  [..]   [...]
  212     1
  128     1
  121     1
  52      0
  23      0 
  11      0
  </code></pre>