国产成人毛片视频|星空传媒久草视频|欧美激情草久视频|久久久久女女|久操超碰在线播放|亚洲强奸一区二区|五月天丁香社区在线|色婷婷成人丁香网|午夜欧美6666|纯肉无码91视频

sql連續(xù)登錄5天以上用戶 查連續(xù)5天登陸的用戶,sql怎么寫?

查連續(xù)5天登陸的用戶,sql怎么寫?新增用戶登陸日志表(id、user_id、login_time、login_date)用戶表新增連續(xù)登陸天數(shù)字段(continuous_days);用戶每次登陸往登

查連續(xù)5天登陸的用戶,sql怎么寫?

新增用戶登陸日志表(id、user_id、login_time、login_date)用戶表新增連續(xù)登陸天數(shù)字段(continuous_days);用戶每次登陸往登陸日志表insert記錄,并且查看昨天是否有登陸記錄,如果昨天登陸記錄大于0,則連續(xù)登陸天數(shù) 1,否則將連續(xù)登陸天數(shù)置為0;sql語句:select*fromuserwhere continuous_days>5

SQL語句如何查詢各個(gè)用戶最長的連續(xù)登陸天數(shù)?

最簡單的子查詢:select * from table where date = (select max(date) from table)

或者用輪子哥講的join自己:

select * from table t1 left join (select max(date) as date from table) t2 on t1.date=t2.date where t2.date is not null