Skip to content
Last updated

Access Frequency Example

The distribution of access frequency. This is useful to see the distribution of user engagement.

Access Frequency Query Example for Hive and Presto

SELECT 
  T.cnt,
  COUNT(1) AS frequency
FROM (
    SELECT 
      user_id,
      COUNT(1) AS cnt
    FROM
      access
    GROUP BY
      user_id
  ) T
GROUP BY
  T.cnt
ORDER BY
  frequency

Sample Input

timeuser_id
14164355852
14164355863
14164355875
14164355881
......

Sample Output

cntfrequency
1621
2121
371
461
541
631
711
83
91