1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| create table T1
( id_user integer not null
, update_date date not null
)
;
insert into T1 (id_user, update_date)
values (1, '2022-10-05')
, (1, '2018-11-16')
, (3, '2020-04-08')
, (2, '2023-05-30')
, (1, '2019-06-22')
, (1, '2019-07-28')
, (2, '2022-11-11')
, (2, '2022-11-15')
;
select TA.id_user as ID
, TA.update_date as DT
, count(*) as RK
from T1 as TA
left join T1 as TB
on TB.id_user=TA.id_user
and TB.update_date>=TA.update_date
group by TA.id_user
, TA.update_date |
Partager