SQL Basics

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDatabasesSQL Basics

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old December 3rd, 2012, 03:11 AM
10e5x 10e5x is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 2 10e5x User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 6 sec
Reputation Power: 0
Very difficult qns!!! How to derive entry and exit time from 1 messy db.

Hi all,
I am faced with a very troubled scenario. I am given a .mdb from access 2003. The data are so messy and i am tasked to derive the working hrs. After trying for quite some time, i still unable to get it. Therefore have to post it here, hoping that some pro here can help me derive the sql statements.


TACS table:
EventDate StaffName EventTime Message
21/11/12 John 23:01:00 OUT
21/11/12 Peter 23:10:00 IN
21/11/12 Peter 23:10:05 IN
22/11/12 John 07:19:00 IN
22/11/12 Peter 07:20:00 OUT
22/11/12 Joe 07:30:00 IN
22/11/12 Mike 08:00:00 IN
22/11/12 John 17:00:00 OUT
22/11/12 John 17:01:00 OUT
22/11/12 Joe 19:01:00 OUT
22/11/12 Mike 19:30:00 OUT
22/11/12 Mary 22:00:00 IN
23/11/12 John 07:01:00 IN
23/11/12 Mary 08:00:00 OUT
23/11/12 Peter 09:00:00 IN


What i want to derive.
FinalTable:
ID EntryDT ExitDT SName WrkHrs
1 Unknow 21/11/12 23:01:00 John Unknown
2 21/11/12 23:10:05 22/11/12 07:20:00 Peter 8hrs10mins
3 22/11/12 07:19:00 22/11/12 17:00:00 John 9hrs41mins
4 22/11/12 07:30:00 22/11/12 19:01:00 Joe 11hrs31min
5 22/11/12 08:00:00 22/11/12 19:30:00 Mike 11hrs30min
6 22/11/12 22:00:00 23/11/12 08:00:00 Mary 10hrs
7 23/11/12 07:01:00 Unknow John Unknown
8 23/11/12 09:00:00 Unknow Peter Unknown


My logic is that first check the message is it in or out. In signifies clockIn. If there are multiple clock in before out, i will use the latest clockIn as EntryDT, and vice versa, use the latest clockOut as ExitDT. However due to the mess, i dk how to write a statement to allow the prog to know which timing are for which event. Lastly if there are no respective clock in or out, it will be left unknown.

Any help will be greatly appreciated.

Thanks,
10e5x

Reply With Quote
Reply

Viewing: Tutorialized ForumsDatabasesSQL Basics > Very difficult qns!!! How to derive entry and exit time from 1 messy db.


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap