mysql 怎么实现同一天多次登录认为是一次

mysql 怎么实现同一天多次登录认为是一次,第1张

select name,count(distinct date_format(lastlogon,'%Y-%m-%d')) 登录次数,max(lastlogon) 最后登录时间 from 表名 group by name

其中count(distinct date_format(lastlogon,'%Y-%m-%d'))代表按照年月日去重后的次数。

max(lastlogon)代表最大的登录时间,也就是最近的登录时间。

select CAST(startTime AS DATE) startTime,count(*) as a,

sum(case when serviceType='转办' then 1 else 0 end ) as b,

sum(case when endTime>now() then 1 else 0 end ) as c,

sum(case when callType='重复投诉' then 1 else 0 end ) as d,

sum(case when callType='咨询' then 1 else 0 end ) as e,

sum(case when callType='投诉举报' then 1 else 0 end ) as f,

sum(case when callType='求助' then 1 else 0 end ) as j,

sum(case when callType='建议' then 1 else 0 end ) as m,

sum(case when callType='表扬' then 1 else 0 end ) as n,

sum(case when callType='感谢' then 1 else 0 end ) as z

from opeform where startTime>='2015-6-1' and startTime<='2015-11-1'

group by CAST(startTime AS DATE)

这样改试一下


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/7341812.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-04
下一篇 2023-04-04

发表评论

登录后才能评论

评论列表(0条)

保存