[问题点数:100分,结帖人jouky]
等级
本版专家分:0
结帖率 100%
record 表有ManID,TheDatetime两字段,人每刷一次卡即有一条数据,比如:
现要找出每天刷卡大于3次的人员记录,并先按日期,再按人列出具体刷卡时间明细
这个SQL查询语句该怎么写啊?各位帮帮忙,哈哈,谢谢,谢谢!
展开阅读全文
等级
本版专家分:5785
select * from record a
where (select count(*) from record
where ManID=a.ManID
and datediff(TheDatetime,a.TheDatetime)=0
)>3
等级
本版专家分:923
试试
select * from record
group by TheDatetime,ManID
having count(Mandid)>=3 and count(convert(char(10),TheDatetime,102))>=3
等级
本版专家分:5785
select * from record a
where (select count(*) from record
where ManID=a.ManID
and datediff(TheDatetime,a.TheDatetime)=0
)>3
order by cast(convert(varchar(8),TheDatetime,112) as datetime),ManID,TheDatetime
等级
本版专家分:1472
select ManID,TheDatetime
from record
where ManID in (select ManID,count(*) from record group by ManID,convert(varchar(20),TheDatetime,112) having count(*)>3 )
order by TheDatetime,ManID
等级
本版专家分:12816
select a.*
fro