Click here to Skip to main content
15,888,136 members
Home / Discussions / Database
   

Database

 
GeneralRe: Oracle Express Question Pin
Richard MacCutchan7-Feb-14 23:21
mveRichard MacCutchan7-Feb-14 23:21 
GeneralRe: Oracle Express Question Pin
Jörgen Andersson7-Feb-14 23:02
professionalJörgen Andersson7-Feb-14 23:02 
AnswerRe: Oracle Express Question Pin
Bernhard Hiller10-Feb-14 21:41
Bernhard Hiller10-Feb-14 21:41 
QuestionTable Name Pin
Sandeep Singh Shekhawat7-Feb-14 20:25
professionalSandeep Singh Shekhawat7-Feb-14 20:25 
AnswerRe: Table Name Pin
Mycroft Holmes7-Feb-14 20:35
professionalMycroft Holmes7-Feb-14 20:35 
Questionpassing data from one action to another MVC asp.net Pin
Hunain Hafeez7-Feb-14 2:49
Hunain Hafeez7-Feb-14 2:49 
SuggestionRe: passing data from one action to another MVC asp.net Pin
Richard Deeming7-Feb-14 4:07
mveRichard Deeming7-Feb-14 4:07 
Questionsum of time per month Pin
Hunain Hafeez5-Feb-14 21:10
Hunain Hafeez5-Feb-14 21:10 
This query shows emplName,emplID, totalworking time, InTime, OutTime, DateVisited, Overtime for an employee based on his InTime and Outime, that's OK. Now i am trying to modify it to show only emplID, EmplName, Total Working hours(Per month), total overtime (per month).

e.g.

SQL
Empid   EmplName  TotalWorkingHours TotalOvertime  Month
00001   John      77:00               05:55       2013-02
00002   Masn      57:00               04:56       2013-02

Query:

SQL
with times as (
SELECT    t1.EmplID
        , t3.EmplName
        , min(t1.RecTime) AS InTime
        , max(t2.RecTime) AS [TimeOut]
        , t4.ShiftId as ShiftID
        , t4.StAtdTime as ShStartTime
        , t4.EndAtdTime as ShEndTime
        , cast(min(t1.RecTime) as datetime) AS InTimeSub
        , cast(max(t2.RecTime) as datetime) AS TimeOutSub
        , t1.RecDate AS [DateVisited]
FROM  AtdRecord t1 
INNER JOIN 
      AtdRecord t2 
ON    t1.EmplID = t2.EmplID 
AND   t1.RecDate = t2.RecDate
AND   t1.RecTime < t2.RecTime
inner join 
      HrEmployee t3 
ON    t3.EmplID = t1.EmplID 
inner join AtdShiftSect t4
ON t3.ShiftId = t4.ShiftId
group by 
          t1.EmplID
        , t3.EmplName
        , t1.RecDate
        , t4.ShiftId 
        , t4.StAtdTime 
        , t4.EndAtdTime
)
SELECT 
 EmplID
,EmplName
,ShiftId As ShiftID
,InTime
,[TimeOut]
,convert(char(5),cast([TimeOutSub] - InTimeSub as time), 108) TotalWorkingTime
,[DateVisited]
,CASE WHEN [InTime] IS NOT NULL AND [TimeOut] IS NOT NULL THEN
     CONVERT(char(5),CASE WHEN  CAST([TimeOutSub] AS DATETIME) >= ShEndTime And ShiftID = 'S002' Then  LEFT(CONVERT(varchar(12), DATEADD(ms, DATEDIFF(ms, CAST(ShEndTime AS DATETIME),CAST([TimeOutSub] AS DATETIME)),0), 108),5) 
                          WHEN  CAST([TimeOutSub] AS DATETIME) >= ShEndTime And ShiftID = 'S001' Then  LEFT(CONVERT(varchar(12), DATEADD(ms, DATEDIFF(ms, CAST(ShEndTime AS DATETIME),  CAST([TimeOutSub] AS DATETIME)),0), 108),5) 
      ELSE '00:00' END, 108) 
 ELSE 'ABSENT' END AS OverTime
 FROM times order by EmplID, ShiftID, DateVisited

AnswerRe: sum of time per month Pin
Shameel5-Feb-14 23:25
professionalShameel5-Feb-14 23:25 
GeneralRe: sum of time per month Pin
Hunain Hafeez5-Feb-14 23:44
Hunain Hafeez5-Feb-14 23:44 
AnswerRe: sum of time per month Pin
King Fisher7-Feb-14 2:24
professionalKing Fisher7-Feb-14 2:24 
Questionputting column 00:00 Pin
Hunain Hafeez4-Feb-14 23:46
Hunain Hafeez4-Feb-14 23:46 
AnswerRe: putting column 00:00 Pin
Chris Quinn5-Feb-14 5:04
Chris Quinn5-Feb-14 5:04 
AnswerRe: putting column 00:00 Pin
Mycroft Holmes5-Feb-14 11:57
professionalMycroft Holmes5-Feb-14 11:57 
Questioncommand implement loop Pin
mrkeivan3-Feb-14 21:11
mrkeivan3-Feb-14 21:11 
AnswerRe: command implement loop Pin
Chris Quinn3-Feb-14 21:20
Chris Quinn3-Feb-14 21:20 
GeneralRe: command implement loop Pin
mrkeivan3-Feb-14 21:28
mrkeivan3-Feb-14 21:28 
GeneralRe: command implement loop Pin
Chris Quinn3-Feb-14 22:02
Chris Quinn3-Feb-14 22:02 
GeneralRe: command implement loop Pin
Richard Andrew x645-Feb-14 4:56
professionalRichard Andrew x645-Feb-14 4:56 
GeneralRe: command implement loop Pin
Chris Quinn5-Feb-14 4:59
Chris Quinn5-Feb-14 4:59 
GeneralRe: command implement loop Pin
Richard Andrew x645-Feb-14 5:00
professionalRichard Andrew x645-Feb-14 5:00 
AnswerRe: command implement loop Pin
Jörgen Andersson4-Feb-14 5:04
professionalJörgen Andersson4-Feb-14 5:04 
GeneralRe: command implement loop Pin
mrkeivan7-Feb-14 18:51
mrkeivan7-Feb-14 18:51 
QuestionThe meaning of the Roles in SQL Server 2008 R2 Pin
Lefteris Gkinis3-Feb-14 6:18
Lefteris Gkinis3-Feb-14 6:18 
AnswerRe: The meaning of the Roles in SQL Server 2008 R2 Pin
Eddy Vluggen3-Feb-14 9:57
professionalEddy Vluggen3-Feb-14 9:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.