Cumulative distinct count

前端 未结 4 1621
北海茫月
北海茫月 2021-02-06 14:37

I am working on query to get cumulative distinct count of uids on daily basis.

Example : Say there are 2 uids (100,200) appeared on date 2016-11-01 and they also appea

4条回答
  •  深忆病人
    2021-02-06 15:18

    easiest way:

    SELECT *, count(*) over (order by fst_date ) cum_uids
      FROM (
    SELECT uid, min(date) fst_date FROM t GROUP BY uid
     ) t
    

    or something like this

提交回复
热议问题