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

Database

 
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 
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 
i have written this query to show total working time and overtime of an employee on particular date (if he has came) otherwise it doesn't show record for a person if his INTIME and TIMEOUT are empty but i don't want this now, i want if for a particular date person's INtime and OutTime are empty then put 00:00 in his intime, outtime, totalworkingtime, overtime.

e.g.

SQL
EmplID  EmplName ShiftID intime Outtime totalworking overtime  dateVisited
0000001 John     S001    00:00  00:00   00:00:       00:00     2013-12-01

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: 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 
QuestionHow to get last 3 values from Mysql table Pin
Member 1026351931-Jan-14 22:20
Member 1026351931-Jan-14 22:20 
AnswerRe: How to get last 3 values from Mysql table Pin
Snehasish_Nandy1-Feb-14 0:09
professionalSnehasish_Nandy1-Feb-14 0:09 
GeneralRe: How to get last 3 values from Mysql table Pin
Member 102635191-Feb-14 1:06
Member 102635191-Feb-14 1:06 
AnswerRe: How to get last 3 values from Mysql table Pin
Eddy Vluggen1-Feb-14 7:13
professionalEddy Vluggen1-Feb-14 7:13 

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.