Can somebody help me with my problem in sql... I have an attendancelog table where i have 3 columns Date, EmpID, IN/OUT, Date and Time. I would like to transfer this data in another column where it has Date, EmpID, IN Date and Time Column, and OUT Date and Time Column. I'm just new in sql i dont know how to implement it.
I am using sql server 2000. I have already a table with data in the first table. I need to transfer the data in the second table
For example:
1st Table Contain Logs
Column Date EmpID IN/OUT Date and Time
10/11/2007 20 IN 10/11/2007 11:00 AM
10/11/2007 1 IN 10/11/2007 11:10 AM
10/11/2007 1 OUT 10/11/2007 10:00 PM
10/12/2007 20 OUT 10/12/2007 6:00 AM
I would like to transfer the IN and OUT of the the same EmpID to a single row
2nd Table Date EmpID DateTime IN DateTime OUT
10/11/2007 20 10/11/2007 11:00 AM 10/12/2007 6:00 AM
10/11/2007 1 10/11/2007 11:10 AM 10/11/2007 10:00 PM
3 1448
Can somebody help me with my problem in sql... I have an attendancelog table where i have 3 columns Date, EmpID, IN/OUT, Date and Time. I would like to transfer this data in another column where it has Date, EmpID, IN Date and Time Column, and OUT Date and Time Column. I'm just new in sql i dont know how to implement it.
I am using sql server 2000. I have already a table with data in the first table. I need to transfer the data in the second table
For example:
1st Table Contain Logs
Column Date EmpID IN/OUT Date and Time
10/11/2007 20 IN 10/11/2007 11:00 AM
10/11/2007 1 IN 10/11/2007 11:10 AM
10/11/2007 1 OUT 10/11/2007 10:00 PM
10/12/2007 20 OUT 10/12/2007 6:00 AM
I would like to transfer the IN and OUT of the the same EmpID to a single row
2nd Table Date EmpID DateTime IN DateTime OUT
10/11/2007 20 10/11/2007 11:00 AM 10/12/2007 6:00 AM
10/11/2007 1 10/11/2007 11:10 AM 10/11/2007 10:00 PM
try: -
select in.date, in.empid, in.datetimeIN, out.datetimeout
-
from
-
(select date, empid, datetime as datetimein from FirstTable where [in/out] ='IN') full outer join
-
(select date, empid, datetime as datetimeout from FirstTable where [in/out] ='OUT') out on in.empid = out.empid
-
-
Happy Coding!
-- CK
It wont to work...
The following are the fullname of the tables:
wherein the [LogTransType] = [LogTransDesc]
0 IN
1 OUT
From this data
[LogDate] [LogEmpID] [LogTransType] [LogTransDesc] [LogDateTime]
10/11/2007 20 0 IN 10/11/2007 11:00 AM
10/11/2007 10 0 IN 10/11/2007 11:10 AM
10/11/2007 10 1 OUT 10/11/2007 10:00 PM
10/12/2007 20 1 OUT 10/12/2007 6:00 AM
To this data
[LogDate] [LogEmpID] [LogIN] [LogOUT]
10/11/2007 20 10/11/2007 11:00 AM 10/12/2007 6:00
10/11/2007 10 10/11/2007 11:10 AM 10/11/2007 10:00
Please help again...
Thanks... for the code. The code really works its just it was missing an in alias before the FULL OUTER JOIN.
Thanks for helping
Sign in to post your reply or Sign up for a free account.
Similar topics
by: konsu |
last post by:
hello,
i need to implement a secure web site in php and mysql but i have just
started looking at php a few days ago, and i would appreciate any advice
from the experts.
the site, as i said,...
|
by: Peter Brown |
last post by:
Hello!
I am stepping through a text book that sets up different websites. The
one I am testing is user registration.
I set up the scripts and this is what I observe:
Login (verifying...
|
by: MichaelR |
last post by:
I have an asp.net application using forms authentication.
1. It has a simple login page (login.aspx) that uses
FormsAuthentication.RedirectFromLoginPage(. . . ).
2. My application has a logout...
|
by: ad |
last post by:
I use Login control's Authenticate event to authenticate use.
I find that different users can use the same ID to login in the same time.
How can I restrict that the some ID can only login once in...
|
by: ShailShin |
last post by:
Hi All,
Developing an VB App for Login and logout tracking.
In App Form there are two buttons login and logout. When user click on login the loginName, LoginTime and LoginDate get stored in...
|
by: Dan |
last post by:
Hi,
I use the logon control for logging into the application. When logging and
checking the option "remember me next time" and then closing the browser
without to press any logout button which...
|
by: André |
last post by:
Hi,
When clicking on "remember me" when logging, the user asks for not to have
to log in next time he visits the site.
Now, on one side, i read it is recommended to logout properly (clicking...
|
by: Kandiman |
last post by:
Hiya, i made a asp page, and one of my divs (as a include) is as below. the problem is if the main page is resubmitted, i get logged out again?...
heres the code.. i think its on the value=true...
|
by: Adrock952 |
last post by:
I have a link on my site which obviously says "Login" where users log in.
I would like that link to be changed to "Logout" when the user has successfully logged in and the session has been created...
|
by: DavidPr |
last post by:
When I logout as one user and log in under a different user, it opens with the last user's information.
User 1 - Unsername: Davey Jones
User 2 - Unsername: David Smith
I log out from Davey...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |