November 24, 2008 at 7:39 pm
TABLE 1 TABLE 2
Employee Hierarchy
================================================
Emp_Number Territory
Emp_First_Name Report_to
Emp_Last_Name Terr_ID
Territory_type_id Territory_type_id
Employment_Type
Here in tables 'Employee' and 'Hierarchy' Territory_type_id can be as follows:
REP - sales representative
DM - district manager
RM - regional manager
Representative in Territory(int(5)) reports to Report_to(int(5)).
----------
So please can you let me know the which SQL functionality will be better to query?
In my point of view, it can be "Self-Join" ????????
Please reply soon. Thanks in advance. Your help appreciated.
Devam
November 24, 2008 at 8:44 pm
You have no rational way to relate Employee ahd Heirarchy.
Please read this article on how to get better results from these forums: http://www.sqlservercentral.com/articles/Best+Practices/61537/.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
November 25, 2008 at 12:21 am
What exactly you are trying to query?
If you want find out the employees and whom they are reporting to, you may do the following.
Join Employee to Hierarchy on Territory_type_id
Join another Employee (Say alias E2) to Hierarchy on Report_to=E2.Emp_Number. In the select list include fields from Employee and E2 ('Manager's' information).
November 25, 2008 at 5:31 am
A "self Join" is when a single table is joined back to itself. You have two tables.
Can you better define what it is you're trying to do?
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
November 25, 2008 at 9:30 am
sorry for the confusion. But the thing is that forget Emp Number.
what i m trying to find is : Territory and Report_To are in relationship in same
'Hierarchy' table.
I gonna explain ... Like this "Representative with Territory(int(5))' reports to the District Manager
with the Territory number represented by Reprt_To(int(5)) .... Here Report_To is nothing but
the number stating that one emp reports to this emp.
Example: Rep reports to District manager.
District Manager reports to Regional Manager .... likewise.!!!!!
So i want those Emp_FName and Emp_LName from Employee table ... that have
Territory_ID same as Territory_ID in 'Hierarchy' Table (say 'RM') ....
and further I want those Territory_Id from 'Hierarchy' table that has Territory (int(5)) = Report_To(int(5))
Hope .. you got it now guys.
Thanks for all suggestions and feedback. More feedback is apprecuated.
THANKS A LOT !!
-DEVAM
November 25, 2008 at 1:10 pm
devammehta (11/25/2008)
Hope .. you got it now guys.
Umm, No. You still have no way to relate the Employee table to the Hierarchy table. Please read the article mentioned in my previous post and then respond with the information that it suggests.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
November 25, 2008 at 3:14 pm
One more question - Can anyone provide me with the article or a good book
to dowload from the web or any kind of good source ... for ... "Integrating the
SQL Server Reporting Service Reports" build in Visual BI Studio with the ASP .NET
Web Application/Website and back hand coding if any in Csharp.
Thanks for all your help.
- 🙂 DEVAM
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply