| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 5978 人关注过本帖
标题:求助purana给个学VB的秘方
只看楼主 加入收藏
西风独自凉
Rank: 8Rank: 8
等 级:贵宾
威 望:43
帖 子:3380
专家分:28
注 册:2007-8-2
收藏
得分:0 

要命啊。///这么长。。看样子中秋的假是完了

Select K.*,A.OverTotal From
(Select empl_Code,Sum(Case When OverTime Is Null Then 0 Else OverTime End) As OverTotal From
(Select A.*,B.NoonIn,B.NoonOut,C.NightIn,C.NightOut,Convert(Decimal(9,2),Convert(Decimal(9,2),DateDiff(Mi,MorningIn,MorningOut) +
DateDiff(Mi,NoonIn,NoonOut) + DateDiff(Mi,NightIn,NightOut))/60) - 8 As Overtime From
(Select Attendance.empl_Code,NowDate,
Min(Case When Convert(char(8),DHTime,8) Between '07:35:00' And '08:30:00' --Ν痁秈
Then '08:00:00' End) As MorningIn,
Max(Case When Convert(char(8),DHTime,8) Between '11:56:00' And '12:15:00' --Ν痁?
Then '12:00:00' End ) As MorningOut From Attendance
Left Join Bhr on Attendance.empl_Code=Bhr.empl_Code
Where Attendance.Dept_Name=Bhr.Dept_Name And Bhr.Group_Name= 'ó?┬' And DatePart(dw,NowDate) Between 2 And 6
Group By Attendance.empl_Code,NowDate) As A

Left Join

(Select Attendance.empl_Code,NowDate,
Min(Case When Convert(char(8),DHTime,8) Between '13:00:00' And '13:35:00' --い痁秈
Then '13:30:00' End) As NoonIn,
Max(Case When Convert(char(8),DHTime,8) Between '17:20:00' And '17:45:00' --い痁?
Then '17:30:00' End ) As NoonOut From Attendance
Left Join Bhr on Attendance.empl_Code=Bhr.empl_Code
Where Attendance.Dept_Name=Bhr.Dept_Name And Bhr.Group_Name= 'ó?┬' And DatePart(dw,NowDate) Between 2 And 6
Group By Attendance.empl_Code,NowDate ) As B on A.empl_Code=B.empl_Code
And A.NowDate=B.NowDate

Left Join

(Select Attendance.empl_Code,NowDate,
Min(Case When Convert(char(8),DHTime,8) Between '18:15:00' And '18:35:00' --边痁秈
Then '18:30:00' End) As NightIn,
Max(Case When Convert(Char(8),DHTime,8) > '18:30:00' Then --边痁?
CASE When datepart(mi, DHTime) Between 0 AND 24
Then Convert(Char(8),RIGHT('00' + RTRIM(Convert(Char(2),DatePart(hh, DHTime))),2) + ':' + '00:00' ,8)
When datepart(mi, DHTime) BETWEEN 25 AND 54
Then Convert(Char(8), RIGHT('00' + RTRIM(Convert(Char(2),DatePart(hh, DHTime))),2) + ':' + '30:00' ,8)
Else Convert(Char(8),DateAdd(mi, 60 - Datepart(mi,dhtime),DHTime))
End
End ) As NightOut From Attendance
Left Join Bhr on Attendance.empl_Code=Bhr.empl_Code
Where Attendance.Dept_Name=Bhr.Dept_Name And Bhr.Group_Name= 'ó?┬' And DatePart(dw,NowDate) Between 2 And 6
Group By Attendance.empl_Code,NowDate ) As C
On A.empl_Code=C.empl_Code And A.NowDate=C.NowDate
) As H Group By empl_Code) As A

Left Join

(Select A.*,B.NoonIn,B.NoonOut,C.NightIn,C.NightOut,Convert(Decimal(9,2),Convert(Decimal(9,2),DateDiff(Mi,MorningIn,MorningOut) +
DateDiff(Mi,NoonIn,NoonOut) + DateDiff(Mi,NightIn,NightOut))/60) - 8 As Overtime From
(Select Attendance.empl_Code,NowDate,
Min(Case When Convert(char(8),DHTime,8) Between '07:35:00' And '08:30:00' --Ν痁秈
Then '08:00:00' End) As MorningIn,
Max(Case When Convert(char(8),DHTime,8) Between '11:56:00' And '12:15:00' --Ν痁?
Then '12:00:00' End ) As MorningOut From Attendance
Left Join Bhr on Attendance.empl_Code=Bhr.empl_Code
Where Attendance.Dept_Name=Bhr.Dept_Name And Bhr.Group_Name= 'ó?┬' And DatePart(dw,NowDate) Between 2 And 6
Group By Attendance.empl_Code,NowDate) As A

Left Join

(Select Attendance.empl_Code,NowDate,
Min(Case When Convert(char(8),DHTime,8) Between '13:00:00' And '13:35:00' --い痁秈
Then '13:30:00' End) As NoonIn,
Max(Case When Convert(char(8),DHTime,8) Between '17:20:00' And '17:45:00' --い痁?
Then '17:30:00' End ) As NoonOut From Attendance
Left Join Bhr on Attendance.empl_Code=Bhr.empl_Code
Where Attendance.Dept_Name=Bhr.Dept_Name And Bhr.Group_Name= 'ó?┬' And DatePart(dw,NowDate) Between 2 And 6
Group By Attendance.empl_Code,NowDate ) As B on A.empl_Code=B.empl_Code
And A.NowDate=B.NowDate

Left Join

(Select Attendance.empl_Code,NowDate,
Min(Case When Convert(char(8),DHTime,8) Between '18:15:00' And '18:35:00' --边痁秈
Then '18:30:00' End) As NightIn,
Max(Case When Convert(Char(8),DHTime,8) > '18:30:00' Then --边痁?
CASE When datepart(mi, DHTime) Between 0 AND 24
Then Convert(Char(8),RIGHT('00' + RTRIM(Convert(Char(2),DatePart(hh, DHTime))),2) + ':' + '00:00' ,8)
When datepart(mi, DHTime) BETWEEN 25 AND 54
Then Convert(Char(8), RIGHT('00' + RTRIM(Convert(Char(2),DatePart(hh, DHTime))),2) + ':' + '30:00' ,8)
Else Convert(Char(8),DateAdd(mi, 60 - Datepart(mi,dhtime),DHTime))
End
End ) As NightOut From Attendance
Left Join Bhr on Attendance.empl_Code=Bhr.empl_Code
Where Attendance.Dept_Name=Bhr.Dept_Name And Bhr.Group_Name= 'ó?┬' And DatePart(dw,NowDate) Between 2 And 6
Group By Attendance.empl_Code,NowDate ) As C
On A.empl_Code=C.empl_Code And A.NowDate=C.NowDate ) As K
On A.empl_Code=K.empl_Code Where K.NowDate Between Convert(Char(8),GetDate(),120) + '01' And Convert(Char(10),GetDate(),120)
Order By A.empl_Code


2007-09-24 20:07
随风逐流
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:passerby
等 级:版主
威 望:8
帖 子:4054
专家分:271
注 册:2007-6-13
收藏
得分:0 
你也是做日本项目?

[url=http://www./html/6/6694/]极道金丹[/url][url=http://www./html/2/2849/]九阴九阳[/url][url=http://www./html/2/2596/]凡人修仙传[/url]
2007-09-24 20:08
西风独自凉
Rank: 8Rank: 8
等 级:贵宾
威 望:43
帖 子:3380
专家分:28
注 册:2007-8-2
收藏
得分:0 
那是乱码。。。。

2007-09-24 20:09
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
收藏
得分:0 
我没写过这么长的查询..

我的msn: myfend@
2007-09-24 20:11
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
收藏
得分:0 
你是在哪看的?

我的msn: myfend@
2007-09-24 20:12
西风独自凉
Rank: 8Rank: 8
等 级:贵宾
威 望:43
帖 子:3380
专家分:28
注 册:2007-8-2
收藏
得分:0 
我也没写过。。。。我们老大叫我看。。
怎么看啊。。。我的中秋节。。难道就要和这段代码一起过。

2007-09-24 20:14
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
收藏
得分:0 

不过这查询..也不是很复杂..
只是几个left join而已.

我的msn: myfend@
2007-09-24 20:18
西风独自凉
Rank: 8Rank: 8
等 级:贵宾
威 望:43
帖 子:3380
专家分:28
注 册:2007-8-2
收藏
得分:0 
是啊。。但是有那么多表。。又这么长。。。不敢去看了。。我的中秋节。

2007-09-24 20:20
随风逐流
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:passerby
等 级:版主
威 望:8
帖 子:4054
专家分:271
注 册:2007-6-13
收藏
得分:0 

中秋不放假的吧?


[url=http://www./html/6/6694/]极道金丹[/url][url=http://www./html/2/2849/]九阴九阳[/url][url=http://www./html/2/2596/]凡人修仙传[/url]
2007-09-24 20:21
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
收藏
得分:0 

中秋节..本来就不用过..
今年中秋节..刮台风..下雨.

我的msn: myfend@
2007-09-24 20:22
快速回复:求助purana给个学VB的秘方
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.048767 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved