Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Query help


Query help

Author
Message
SQL_Surfer
SQL_Surfer
Old Hand
Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)

Group: General Forum Members
Points: 398 Visits: 1076
I have a table that has EmployeeID, EmployeeLoginDateTime and What JobFunction they logged in under. JobFunction is like Developing, Coding, Programming, Adminstering and LogOut.I need to write a query which pulls all the users and the day that they didn't log out.

Any help would be approciated.
SQL_Starter
SQL_Starter
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 38
Compare the Login date and logout date using where clause.. To get the day out from the Login date use string functions.. I think it works,...
ColdCoffee
ColdCoffee
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2315 Visits: 5545
SQL_Surfer (3/14/2012)
Any help would be approciated.

Sure. But help us first!

There is menu card in that hotel! I want you to buy me a lunch from that menu card! Can you?
J Livingston SQL
J Livingston SQL
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: General Forum Members
Points: 3443 Visits: 32983
SQL_Surfer (3/14/2012)
I have a table that has EmployeeID, EmployeeLoginDateTime and What JobFunction they logged in under. JobFunction is like Developing, Coding, Programming, Adminstering and LogOut.I need to write a query which pulls all the users and the day that they didn't log out.

Any help would be approciated.


if they didnt log out...can we assume "LogOut" is Null?

________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day

SQL_Surfer
SQL_Surfer
Old Hand
Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)

Group: General Forum Members
Points: 398 Visits: 1076
If they forget to Logout, there won't be LogOut records. Or No record for the employee for that day with LogOut jobfunction. I have attached the sample data.
Attachments
SampleData.txt (4 views, 342 bytes)
evelinel1f4r
evelinel1f4r
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 1
To get the day out from the Login date use string functions
SQL_Surfer
SQL_Surfer
Old Hand
Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)

Group: General Forum Members
Points: 398 Visits: 1076
Question is find out all the records for an employee where he didn't log out on a certain day.
ColdCoffee
ColdCoffee
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2315 Visits: 5545
This?

DECLARE @TableA TABLE 
(
EmployeeID      INT
,EmployeeLoginDateTime   DATETIME
,JobFunction VARCHAR(25)
)


INSERT @TableA
SELECT 123,'2012-02-01 01:00:24','Coding'
UNION ALL SELECT 123,'2012-02-01 3:00:00'   ,'Programming'
UNION ALL SELECT 123,'2012-02-01 5:00:00'    ,'LogOut'
UNION ALL SELECT 234,'2012-02-01 01:00:24','Coding'
UNION ALL SELECT 234,'2012-02-01 3:00:00'   ,'Programming'
UNION ALL SELECT 234,'2012-02-01 5:00:00' ,'Coding'


SELECT EmployeeID
   ,EmployeeLoginDateTime
   ,JobFunction
FROM @TableA OutTab
WHERE NOT EXISTS ( SELECT 1 FROM @TableA InrTab
WHERE InrTab.JobFunction = 'LogOut'
AND InrTab.EmployeeID = OutTab.EmployeeID)


SQL_Surfer
SQL_Surfer
Old Hand
Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)

Group: General Forum Members
Points: 398 Visits: 1076
Not quiet. Here, on 2/1, employee 234 didn't logout. So, it should just return 234, 2012/02/01, 'Din't LogOut'. This query is returning all other records but LogOut. I wanted just the ones where they didn't LogOut.
ColdCoffee
ColdCoffee
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2315 Visits: 5545
If there are 20 days that they did not logout, you need all of those 20 days? and u need it for all employees?

Or u need those days that the employee signed in , but forgot to logout?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search