第一,限制每个人每天只能打一次卡 第二:select count(*) as cnt from 打卡记录 where createdate>=开始 and createdate<=结束。最后判断cnt是否大于30
select count(distinct 日期) from ...........这个日期是不带时间的varchar字段,否则要做处理。
SQL Server问题去SQL Server论坛去问吧,那里更专业一些。 给你一个知识:凡是带有“全部”这个算子的计算,如果你没有现成的工具已经封装了它,那么就要转换为“不存在”这个算子来计算。比如查询“每一天都没有迟到”就要转换为对这个查询“存在某一天,这一天迟到了”的否定。凡是all(select * from .....)的查询,如果你的关系数据库没有现成的all子查询功能,就要转换为 not exists(select * from .....)的查询。
select count(distinct(convert(varchar(12), CREATE_TIME,102))) from t_func where FUNC_CREATE_TIME is not null and 日期条件1.注意日期要格式化到"日"在disticnt排重. 2.空日期要排掉
------第一种返回总数----- select count(date)as '总数' from ( select convert(varchar(10),a.regdate,112) as date from userinfo a inner join dbo.UserInfoDetail b on a.userid=b.userid where b.parentuserid=1 and a.regdate between '2010-12-17 00:00:00' and '2012-12-19 00:00:00' group by convert(varchar(10),a.regdate,112)) a----第二种返回条数------- select convert(varchar(10),a.regdate,112) as date,* from userinfo a inner join dbo.UserInfoDetail b on a.userid=b.userid where b.parentuserid=1 and a.regdate between '2010-12-17 00:00:00' and '2012-12-19 00:00:00'我写了2种方法查询的 现在我不晓得后台该怎么判断哪一天没打卡,用死办法可以写,要是天数多了就麻烦了
打卡第一次计算开始时间,DaetTime.adddays或SQL dateadd计算30天后时间 select * from tb where 时间差
select top 1 1 from table where 刷卡=false and 日期>30天前的日期 如果有记录就表示"非全勤" 如果没有记录就表示"全勤"
第二:select count(*) as cnt from 打卡记录 where createdate>=开始 and createdate<=结束。最后判断cnt是否大于30
给你一个知识:凡是带有“全部”这个算子的计算,如果你没有现成的工具已经封装了它,那么就要转换为“不存在”这个算子来计算。比如查询“每一天都没有迟到”就要转换为对这个查询“存在某一天,这一天迟到了”的否定。凡是all(select * from .....)的查询,如果你的关系数据库没有现成的all子查询功能,就要转换为 not exists(select * from .....)的查询。
这是太........如果是专门学过sql课程,那么你的老师看来没有多少文化。
select count(distinct(convert(varchar(12), CREATE_TIME,102)))
from t_func
where FUNC_CREATE_TIME is not null
and 日期条件1.注意日期要格式化到"日"在disticnt排重.
2.空日期要排掉
select count(date)as '总数' from (
select convert(varchar(10),a.regdate,112) as date from userinfo a inner join dbo.UserInfoDetail b
on a.userid=b.userid where b.parentuserid=1 and a.regdate between
'2010-12-17 00:00:00' and '2012-12-19 00:00:00' group by convert(varchar(10),a.regdate,112)) a----第二种返回条数-------
select convert(varchar(10),a.regdate,112) as date,* from userinfo a inner join dbo.UserInfoDetail b
on a.userid=b.userid where b.parentuserid=1 and a.regdate between
'2010-12-17 00:00:00' and '2012-12-19 00:00:00'我写了2种方法查询的 现在我不晓得后台该怎么判断哪一天没打卡,用死办法可以写,要是天数多了就麻烦了
select * from tb where 时间差
如果有记录就表示"非全勤"
如果没有记录就表示"全勤"