惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
AWS News Blog
AWS News Blog
Google DeepMind News
Google DeepMind News
U
Unit 42
博客园 - 叶小钗
博客园 - 聂微东
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
有赞技术团队
有赞技术团队
aimingoo的专栏
aimingoo的专栏
D
DataBreaches.Net
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Jina AI
Jina AI
美团技术团队
The Cloudflare Blog
M
MIT News - Artificial intelligence
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
S
Schneier on Security
C
Check Point Blog
Project Zero
Project Zero
The Hacker News
The Hacker News
Scott Helme
Scott Helme
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Cisco Talos Blog
Cisco Talos Blog
P
Privacy International News Feed
SecWiki News
SecWiki News
Latest news
Latest news
MongoDB | Blog
MongoDB | Blog
S
Secure Thoughts
Google Online Security Blog
Google Online Security Blog
F
Fortinet All Blogs
博客园 - 三生石上(FineUI控件)
H
Help Net Security
TaoSecurity Blog
TaoSecurity Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Last Week in AI
Last Week in AI
P
Privacy & Cybersecurity Law Blog
Forbes - Security
Forbes - Security
G
GRAHAM CLULEY
N
Netflix TechBlog - Medium
L
Lohrmann on Cybersecurity
A
About on SuperTechFans
T
The Exploit Database - CXSecurity.com
C
Cisco Blogs
PCI Perspectives
PCI Perspectives
大猫的无限游戏
大猫的无限游戏
T
Troy Hunt's Blog
H
Hacker News: Front Page
Vercel News
Vercel News

博客园 - kenly33

ORM及代码生成器和插件C#源码(最新版Kenly.DBFramework4.5.8.5) 處理RadioButtonList客戶端事件 - kenly33 - 博客园 对象关系映射架构(DBFramework)及代码生成器和插件(源码) 使對象支持自定義比較 統計分數 讀寫XML文檔 - kenly33 - 博客园 Visual Studio Team System简介 MultiFileUploador GridViewNavigator Gridview梆定 兩個輸入框只允許一個輸入 Gridview中梆定得RadioButton Javascript 隱藏或顯示某區域 ASP.NET 2.0中合并 GridView 的表头单元格 VS2005 RESOURCE MANAGEMENT 鲸鱼哲学 Javascript彈出對話框 FxCop Rules Atlas使用演练
过滤某些字段重复的记录
kenly33 · 2007-06-03 · via 博客园 - kenly33

过滤某些字段重复的记录

CREATE PROCEDURE usp_UniqueAttendRecord (@BeginTime DATETIME,@EndTime DATETIME) 
 AS

SELECT DeptCode,EmpCode,MIN(PDATE) AS 'PDATE' INTO #InTimes FROM attend
WHERE  PDate>@BeginTime AND  PDate<@EndTime AND  iomode='I'
GROUP BY DeptCode,EmpCode,iomode,DATEPART(DAY,PDate)

SELECT DeptCode,EmpCode,MAX(PDATE) AS PDATE INTO #OutTimes FROM attend
WHERE  PDate>@BeginTime AND  PDate<@EndTime AND iomode='O'
GROUP BY DeptCode,empcode,iomode,DATEPART(DAY,PDate)

SELECT A.DeptCode,A.EmpCode,A.PDate AS 'InTime',B.PDate AS 'OutTime'
FROM  #InTimes AS A
LEFT JOIN #OutTimes AS B ON A.EmpCode=B.EmpCode AND DATEPART(YEAR,A.PDate)=DATEPART(YEAR,B.PDate)  AND DATEPART(MONTH,A.PDate)=DATEPART(MONTH,B.PDate) AND DATEPART(DAY,A.PDate)=DATEPART(DAY,B.PDate)
UNION
SELECT A.DeptCode,A.EmpCode,B.PDate AS 'InTime',A.PDate AS 'OutTime'
FROM  #OutTimes AS A
LEFT JOIN #InTimes AS B ON A.EmpCode=B.EmpCode AND DATEPART(YEAR,A.PDate)=DATEPART(YEAR,B.PDate)  AND DATEPART(MONTH,A.PDate)=DATEPART(MONTH,B.PDate) AND DATEPART(DAY,A.PDate)=DATEPART(DAY,B.PDate)
ORDER BY A.DeptCode,A.EmpCode

DROP TABLE #InTimes
DROP TABLE #OutTimes