日期:2014-05-19  浏览次数:20662 次

简单求重复记录
id           processid             createdate

1               1             2007-1-16   9:15:27
1               1             2007-1-16   9:22:27

求   相同一天,相同Id,和相同processid记录个数



------解决方案--------------------
select id,processid,convert(varchar(10),createdate,120) as createdate,count(1) as cou
from tablename
group by id,processid,convert(varchar(10),createdate,120)
------解决方案--------------------
select count(*) from tablename group by id,processid,convert(varchar(10),createdate,120)
------解决方案--------------------
SELECT

[id],
processid,
convert(varchar(10),createdate,112) as createdate,
count(*) as count

FROM tablename

GROUP BY id,processid,convert(varchar(10),createdate,112)

------解决方案--------------------
--try

select id, processid, createdate=convert(char(10), createdate, 120), count(*)
from tbName
group by id, processid, convert(char(10), createdate, 120)

------解决方案--------------------
select id, 天数=convert(varchar(10),createdate,120),记录=count(*)
from 表
group by id,convert(varchar(10),createdate,120)
------解决方案--------------------
select convert(datetime,floor(convert(float, createdate))) as createdate, count(*) from tablename
group by id, processid, convert(datetime,floor(convert(float, createdate)))

主要问题是将日期时间型数据转换为日期,方式很多,上面只是一种