where后面加判断
select [AttendanceCollectId]=newid()
,[MachineId]=[Machine].MachineId
,[MachineCode]=cardinfo.clockid
,[CardId]=[Card].CardId
,[CardCode]=[Card].CardNo
,[EmployeeName]=[Employee].CnName
,[EmployeeCode]=[Employee].Code
,[EmployeeId]=[Employee].EmployeeId
,[ownerId]=[Employee].EmployeeId
,[DepartmentName]=[Department].Name
,[DepartmentId]=[Department].DepartmentId
,[Date] = cardinfo.date+' '+cardinfo.time
,[Time] = cardinfo.time
,[IsManual] = 0
,[Flag] = '1'
,ApproveResultId='OperatorResult_001'
,StateId ='PlanState_003'
,IsForAttendance='1'
--,AttendanceCollectLogId=@AttCollectLogId
from
(select * from (
select right(CONVERT(varchar(16),DATEADD(ss,a.KqTime, cast('00:00:00' AS datetime)), 121),5) time,
CONVERT(varchar(100),a.KqDate, 23) date,
'5'+cast(CardId as varchar) carid,
right(CONVERT(varchar(16), DATEADD(ss,a.KqTime, cast('00:00:00' AS datetime)), 121),5) as checktime,
a.DevID as clockid,
b.employeeid
from [192.168.3.101
].[HsSmartHR170921].dbo.KQ_KqData a,employee b
where b.code=case when @[DepartmentId]=‘NB001000’then '50'+cast(CardId as varchar) else '5'+cast(CardId as varchar) end
and a.EmpSysID is not null ) as info
where not exists (
select top 1 * from
(select [CardCode],[MachineCode],[DateTime]=CONVERT(varchar(100), Date, 23)+' '+CONVERT(varchar(100), Time, 24),employeeid
from [AttendanceCollect])
as collect
where collect.employeeid=info.employeeid
and substring(CONVERT(varchar(100), collect.[DateTime], 20),1,16)=info.date+' '+info.time)
) as cardinfo
left join [Machine] on [Machine].Code = cardinfo.clockid
left join [Card] on [Card].employeeid = cardinfo.employeeid
and [Card].UseTypeId='UseType_001' and ([card].RevokeDate is null or [card].RevokeDate>=GETDATE()-2)
left join [Employee] on [Employee].employeeid= [Card].EmployeeId
left join [Department] on [Department].DepartmentId=[Employee].DepartmentId
where [Card].CardNo is not null and cardinfo.date >='2017-03-01'
,[MachineId]=[Machine].MachineId
,[MachineCode]=cardinfo.clockid
,[CardId]=[Card].CardId
,[CardCode]=[Card].CardNo
,[EmployeeName]=[Employee].CnName
,[EmployeeCode]=[Employee].Code
,[EmployeeId]=[Employee].EmployeeId
,[ownerId]=[Employee].EmployeeId
,[DepartmentName]=[Department].Name
,[DepartmentId]=[Department].DepartmentId
,[Date] = cardinfo.date+' '+cardinfo.time
,[Time] = cardinfo.time
,[IsManual] = 0
,[Flag] = '1'
,ApproveResultId='OperatorResult_001'
,StateId ='PlanState_003'
,IsForAttendance='1'
--,AttendanceCollectLogId=@AttCollectLogId
from
(select * from (
select right(CONVERT(varchar(16),DATEADD(ss,a.KqTime, cast('00:00:00' AS datetime)), 121),5) time,
CONVERT(varchar(100),a.KqDate, 23) date,
'5'+cast(CardId as varchar) carid,
right(CONVERT(varchar(16), DATEADD(ss,a.KqTime, cast('00:00:00' AS datetime)), 121),5) as checktime,
a.DevID as clockid,
b.employeeid
from [192.168.3.101
].[HsSmartHR170921].dbo.KQ_KqData a,employee b
where b.code=case when @[DepartmentId]=‘NB001000’then '50'+cast(CardId as varchar) else '5'+cast(CardId as varchar) end
and a.EmpSysID is not null ) as info
where not exists (
select top 1 * from
(select [CardCode],[MachineCode],[DateTime]=CONVERT(varchar(100), Date, 23)+' '+CONVERT(varchar(100), Time, 24),employeeid
from [AttendanceCollect])
as collect
where collect.employeeid=info.employeeid
and substring(CONVERT(varchar(100), collect.[DateTime], 20),1,16)=info.date+' '+info.time)
) as cardinfo
left join [Machine] on [Machine].Code = cardinfo.clockid
left join [Card] on [Card].employeeid = cardinfo.employeeid
and [Card].UseTypeId='UseType_001' and ([card].RevokeDate is null or [card].RevokeDate>=GETDATE()-2)
left join [Employee] on [Employee].employeeid= [Card].EmployeeId
left join [Department] on [Department].DepartmentId=[Employee].DepartmentId
where [Card].CardNo is not null and cardinfo.date >='2017-03-01'
...全文
相关推荐
ctf中sql注入下的一些小技巧.doc
单行注释符:#、--(需要在 -- 后面留一个空格,因为有的浏览器默认会把空格过滤掉,所以在空格后加一些东西无影响)2.
山东省冠县第一中学七年级英语上册Module3MyschoolUnit2Thelibraryisontheleftoftheplayground课时作业新版外研版
- eighty(八十):30加50等于80。 - behind(在...后面):Tom在我后面,表示位置关系。 - middle(中间):她站在教室的中间。
小学英语连词成句做题技巧.doc
可数名词有复数形式,通常加-s,如"book-books",特殊情况下加-es,如"box-boxes"。不可数名词无复数形式,但可以使用量词表示数量,如"a piece of paper"。
句型转换详解及练习_答案.pdf
**含有be动词的陈述句变否定句**:在be动词后加not。5. **不含be动词的陈述句变否定句**:在动词前加do或does,后面加not。6.
SQL Where的简单判断
### 总结综上所述,“SQL Where的简单判断”实际上涉及到了SQL查询中的高级用法,如自定义函数、集合操作等。


