473,383 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Problem in Join(T-SQL)

Table1:

RouteID RDate Direction RTime Employee_ID ArrTime

R1 6/15/2005 Pick 6/15/2005 9:30:00 AM 1430 6/15/2005 8:12:00 AM
R2 6/15/2005 Pick 6/15/2005 3:00:00 PM 3168 6/15/2005 2:28:00 PM
R2 6/15/2005 Pick 6/15/2005 3:00:00 PM 1430 6/15/2005 1:48:00 PM
R2 6/15/2005 Pick 6/15/2005 3:00:00 PM 1905 6/15/2005 1:42:00 PM
R3 6/15/2005 Pick 6/15/2005 3:00:00 PM 3506 6/15/2005 2:16:00 PM

__________________________________________________ ______________________________________________

Table2:

Employee_ID rDate LoginTime LogoutTime

3474 6/15/2005 6/15/2005 4:45:00 PM 6/16/2005 5:45:00 AM
3493 6/15/2005 6/15/2005 3:00:00 PM 6/16/2005 4:00:00 AM
1430 6/15/2005 6/15/2005 9:30:00 AM 6/15/2005 2:45:00 PM
1827 6/15/2005 6/15/2005 4:45:00 PM 6/16/2005 5:45:00 AM
1905 6/15/2005 6/15/2005 3:00:00 PM 6/16/2005 5:00:00 AM

__________________________________________________ ________________________________________________

I want to select Employee_ID from Table1 who is also found in Table2,
even if there are duplicate records of Employee

Note: Criteria such as RouteID, RTime and ArrTime should not be taken
into considerations while
framing Queries

I faced problem due to there are duplicate records of EMployees(1430)
__________________________________________________ _________________
I have tried like this ( as shown below):

SELECT *
FROM Table1
WHERE RDate = cdate('06/15/2005') and Employee_ID
not in (select TAble2.Employee_ID from Schedule Inner Join Table1 on
Table2.LoginTime = Table1.RTime and Table2.Employee_ID =
Table1.Employee_ID);

Nov 13 '05 #1
1 1314
What you're asking for is quite different from what's in your sample query.
Simply returning a unique list of employees in both Table 1 and Table 2 can
be done like this:

SELECT DISTINCT Table1.EmployeeID FROM Table1 INNER JOIN Table2 ON
Table1.EmployeeID = Table2.EmployeeID

However, your sample suggests that there's more you want to accomplish here.
Could you be more specific?
"mahesh j k" <ma******@gmail.com> wrote in message
news:11********************@o13g2000cwo.googlegrou ps.com...
Table1:

RouteID RDate Direction RTime Employee_ID ArrTime

R1 6/15/2005 Pick 6/15/2005 9:30:00 AM 1430 6/15/2005 8:12:00 AM
R2 6/15/2005 Pick 6/15/2005 3:00:00 PM 3168 6/15/2005 2:28:00 PM
R2 6/15/2005 Pick 6/15/2005 3:00:00 PM 1430 6/15/2005 1:48:00 PM
R2 6/15/2005 Pick 6/15/2005 3:00:00 PM 1905 6/15/2005 1:42:00 PM
R3 6/15/2005 Pick 6/15/2005 3:00:00 PM 3506 6/15/2005 2:16:00 PM

__________________________________________________ __________________________
____________________
Table2:

Employee_ID rDate LoginTime LogoutTime

3474 6/15/2005 6/15/2005 4:45:00 PM 6/16/2005 5:45:00 AM
3493 6/15/2005 6/15/2005 3:00:00 PM 6/16/2005 4:00:00 AM
1430 6/15/2005 6/15/2005 9:30:00 AM 6/15/2005 2:45:00 PM
1827 6/15/2005 6/15/2005 4:45:00 PM 6/16/2005 5:45:00 AM
1905 6/15/2005 6/15/2005 3:00:00 PM 6/16/2005 5:00:00 AM

__________________________________________________ __________________________
______________________
I want to select Employee_ID from Table1 who is also found in Table2,
even if there are duplicate records of Employee

Note: Criteria such as RouteID, RTime and ArrTime should not be taken
into considerations while
framing Queries

I faced problem due to there are duplicate records of EMployees(1430)
__________________________________________________ _________________
I have tried like this ( as shown below):

SELECT *
FROM Table1
WHERE RDate = cdate('06/15/2005') and Employee_ID
not in (select TAble2.Employee_ID from Schedule Inner Join Table1 on
Table2.LoginTime = Table1.RTime and Table2.Employee_ID =
Table1.Employee_ID);

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in...
4
by: David Morgan | last post by:
Hi This is a really weird problem. We have a website that has been running for about six months with no problems. We have recently moved it to a new server with a new ISP. The server is of a...
11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
7
by: Keith Dewell | last post by:
Greetings! My current job has brought me back to working in C++ which I haven't used since school days. The solution to my problem may be trivial but I have struggled with it for the last two...
117
by: Peter Olcott | last post by:
www.halting-problem.com
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
9
by: AceKnocks | last post by:
I am working on a framework design problem in which I have to design a C++ based framework capable of solving three puzzles for now but actually it should work with a general puzzle of any kind and I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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...
0
BarryA
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.