with t2 as ( select l.*, if (l.date = t1.date, 1, null) as is_one from login as l left join ( select user_id, min(date) as date from login ...