473,737 Members | 9,544 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to do this self-join??

al
Greetings,

Would be thankful for your kind help. I have a table (Northwind
employees table). In the employees table, a column called ReportsTo
which lists the EmployeeID, int data type, of the manager of an
employee.This ReportsTo column is basically the EmployeeID column:

EmployeeID Title ReportsTo FirstName SecondName ......
......
1 Manager 4 Steven Buchan
2 Sale Rep. 1 Janet Leverling
3 Clerk 1 Ropert King
4 Presedint Null Andrew Fuller

My question is how can I get the column ReportsTo to include first and
second name, instead of numbers (employeeid).

What I want is something like this(firsname, lastname OR lastname,
firstname for the ReportsTo columen):

EmployeeID Title ReportsTo FirstName SecondName
.... ...
1 Manager Andrew Fuller Steven Buchan
2 Sale Rep. Steven Buchan Janet Leverling
3 Clerk Steven Buchan Ropert King
4 Presedint Null Andrew Fuller

MTIA,
Grawsha
Jul 20 '05 #1
2 4281
"al" <gr*********@ya hoo.com> wrote in message
news:66******** *************** ***@posting.goo gle.com...
Greetings,

Would be thankful for your kind help. I have a table (Northwind
employees table). In the employees table, a column called ReportsTo
which lists the EmployeeID, int data type, of the manager of an
employee.This ReportsTo column is basically the EmployeeID column:

EmployeeID Title ReportsTo FirstName SecondName ......
.....
1 Manager 4 Steven Buchan
2 Sale Rep. 1 Janet Leverling
3 Clerk 1 Ropert King
4 Presedint Null Andrew Fuller

My question is how can I get the column ReportsTo to include first and
second name, instead of numbers (employeeid).

What I want is something like this(firsname, lastname OR lastname,
firstname for the ReportsTo columen):

EmployeeID Title ReportsTo FirstName SecondName
... ...
1 Manager Andrew Fuller Steven Buchan
2 Sale Rep. Steven Buchan Janet Leverling
3 Clerk Steven Buchan Ropert King
4 Presedint Null Andrew Fuller

MTIA,
Grawsha


SELECT E1.EmployeeID,
E1.Title,
E2.FirstName + ' ' + E2.LastName AS ReportsTo,
E1.FirstName,
E1.LastName
FROM Northwind..Empl oyees AS E1
LEFT OUTER JOIN
Northwind..Empl oyees AS E2
ON E2.EmployeeID = E1.ReportsTo

Regards,
jag
Jul 20 '05 #2
al
"John Gilson" <ja*@acm.org> wrote in message news:<C9******* **************@ twister.nyc.rr. com>...
"al" <gr*********@ya hoo.com> wrote in message
news:66******** *************** ***@posting.goo gle.com...
Greetings,

Would be thankful for your kind help. I have a table (Northwind
employees table). In the employees table, a column called ReportsTo
which lists the EmployeeID, int data type, of the manager of an
employee.This ReportsTo column is basically the EmployeeID column:

EmployeeID Title ReportsTo FirstName SecondName ......
.....
1 Manager 4 Steven Buchan
2 Sale Rep. 1 Janet Leverling
3 Clerk 1 Ropert King
4 Presedint Null Andrew Fuller

My question is how can I get the column ReportsTo to include first and
second name, instead of numbers (employeeid).

What I want is something like this(firsname, lastname OR lastname,
firstname for the ReportsTo columen):

EmployeeID Title ReportsTo FirstName SecondName
... ...
1 Manager Andrew Fuller Steven Buchan
2 Sale Rep. Steven Buchan Janet Leverling
3 Clerk Steven Buchan Ropert King
4 Presedint Null Andrew Fuller

MTIA,
Grawsha


SELECT E1.EmployeeID,
E1.Title,
E2.FirstName + ' ' + E2.LastName AS ReportsTo,
E1.FirstName,
E1.LastName
FROM Northwind..Empl oyees AS E1
LEFT OUTER JOIN
Northwind..Empl oyees AS E2
ON E2.EmployeeID = E1.ReportsTo

Regards,
jag

Jag,

Thanks for your help. Does this solution work with CommandBuilder in ADO.NET?

Grawsha
Jul 20 '05 #3

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

Similar topics

2
4713
by: Marc | last post by:
Hi all, I was using Tkinter.IntVar() to store values from a large list of parts that I pulled from a list. This is the code to initialize the instances: def initVariables(self): self.e = IntVar() for part, list in info.masterList.items():
15
2596
by: Ralf W. Grosse-Kunstleve | last post by:
****************************************************************************** This posting is also available in HTML format: http://cci.lbl.gov/~rwgk/python/adopt_init_args_2005_07_02.html ****************************************************************************** Hi fellow Python coders, I often find myself writing:: class grouping:
18
2280
by: Ralf W. Grosse-Kunstleve | last post by:
My initial proposal (http://cci.lbl.gov/~rwgk/python/adopt_init_args_2005_07_02.html) didn't exactly get a warm welcome... And Now for Something Completely Different: class autoinit(object): def __init__(self, *args, **keyword_args): self.__dict__.update(
4
2784
by: David Coffin | last post by:
I'd like to subclass int to support list access, treating the integer as if it were a list of bits. Assigning bits to particular indices involves changing the value of the integer itself, but changing 'self' obviously just alters the value of that local variable. Is there some way for me to change the value of the BitSequence object itself? I've also tried wrapping and delegating using __getattr__, but I couldn't figure out how to handle...
4
1820
by: marek.rocki | last post by:
First of all, please don't flame me immediately. I did browse archives and didn't see any solution to my problem. Assume I want to add a method to an object at runtime. Yes, to an object, not a class - because changing a class would have global effects and I want to alter a particular object only. The following approach fails: class kla: x = 1
7
1909
by: Andrew Robert | last post by:
Hi Everyone, I am having a problem with a class and hope you can help. When I try to use the class listed below, I get the statement that self is not defined. test=TriggerMessage(data) var = test.decode(self.qname)
24
2298
by: Peter Maas | last post by:
The Python FAQ 1.4.5 gives 3 reasons for explicit self (condensed version): 1. Instance variables can be easily distinguished from local variables. 2. A method from a particular class can be called as baseclass.methodname(self, <argument list>). 3. No need for declarations to disambiguate assignments to local/instance variables.
84
7205
by: braver | last post by:
Is there any trick to get rid of having to type the annoying, character-eating "self." prefix everywhere in a class? Sometimes I avoid OO just not to deal with its verbosity. In fact, I try to use Ruby anywhere speed is not crucial especially for @ prefix is better- looking than self. But things grow -- is there any metaprogramming tricks or whatnot we can throw on the self? Cheers,
13
12017
by: Kurda Yon | last post by:
Hi, I found one example which defines the addition of two vectors as a method of a class. It looks like that: class Vector: def __add__(self, other): data = for j in range(len(self.data)): data.append(self.data + other.data)
6
1813
by: Bart Kastermans | last post by:
I am playing with some trees. In one of the procedures I wrote for this I am trying to change self to a different tree. A tree here has four members (val/type/left/right). I found that self = SS does not work; I have to write self.val = SS.val and the same for the other members (as shown below). Is there a better way to do this? In the below self is part of a parse tree, F is the parse tree of a function f with argument x. If a node...
0
8786
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9334
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9258
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8207
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6749
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4569
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4823
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3278
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.