Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Tree Selection

Author  Topic 

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2008-06-13 : 17:46:27

SELECT a.Network_ID, b.Last_Name + ', ' + b.Preferred_FirstName AS full_name, c.Security_Class_Description,
d.Security_Type_Description, a.Security_Value
FROM Company_Hierarchy_Security a
JOIN V_Entity_Employee_Active b on a.Network_ID= b.Network_ID
JOIN Company_Security_Class c on a.Security_Class_Code=c.Security_Class_Code
JOIN Company_Security_Type d on a.Security_Type = d.Security_Type
inner join (select e.Budget_Center_ID + ' - ' + e.Budget_Center_Description As Budget_Center_Description,
f.Company_Name, g.Enterprise_Description, h.Business_Segment_Description,
i.Team_Description
from Company_Hierarchy_Security a.
Inner JOIN Budget_Center e on a.Security_Value = e.Budget_Center_ID
Inner JOIN Company f on a.Security_Value = f.Company_ID
Inner JOIN Enterprise g ON a.Security_Value = Cast(g.Enterprise_Number As Varchar(5))
Inner JOIN Business_Segment h on a.Security_Value = h.Business_Segment_ID
Inner JOIN Team i on a.Security_Value = i.Team_ID


Ok. I have the Security Value located in Company_Hierarchy_Security table. All those values are divided into 5 other tables that I need to join together. I found all of them separate but I have not been able to figue it out how to put it together with the rest of the querie.

Thanks for the help!!!!!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-14 : 00:40:29
May be this:-

SELECT a.Network_ID, b.Last_Name + ', ' + b.Preferred_FirstName AS full_name, c.Security_Class_Description, 
d.Security_Type_Description, a.Security_Value,
tmp.Budget_Center_Description,
tmp.Company_Name, tmp.Enterprise_Description, tmp.Business_Segment_Description,
tmp.Team_Description
FROM Company_Hierarchy_Security a
JOIN V_Entity_Employee_Active b on a.Network_ID= b.Network_ID
JOIN Company_Security_Class c on a.Security_Class_Code=c.Security_Class_Code
JOIN Company_Security_Type d on a.Security_Type = d.Security_Type
inner join (select a1.Network_ID,e.Budget_Center_ID + ' - ' + e.Budget_Center_Description As Budget_Center_Description,
f.Company_Name, g.Enterprise_Description, h.Business_Segment_Description,
i.Team_Description
from Company_Hierarchy_Security a1
Inner JOIN Budget_Center e on a1.Security_Value = e.Budget_Center_ID
Inner JOIN Company f on a1.Security_Value = f.Company_ID
Inner JOIN Enterprise g ON a1.Security_Value = Cast(g.Enterprise_Number As Varchar(5))
Inner JOIN Business_Segment h on a1.Security_Value = h.Business_Segment_ID
Inner JOIN Team i on a1.Security_Value = i.Team_ID)tmp
ON a.Network_ID=tmp.Network_ID


If this is what you're looking for pleas post your table structures with some sample data.
Go to Top of Page

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2008-06-16 : 09:38:05
Thank You visakh16 --- The following section of my querie works but doesn't give the exact information that I need. This is what is giving me:

NetworkId Full Name Sec Class Desc Sec Type Desc Sec Value
tte




SELECT a.Network_ID, b.Last_Name + ', ' + b.Preferred_FirstName AS full_name, c.Security_Class_Description,
d.Security_Type_Description, a.Security_Value
FROM Company_Hierarchy_Security a
JOIN V_Entity_Employee_Active b on a.Network_ID= b.Network_ID
JOIN Company_Security_Class c on a.Security_Class_Code=c.Security_Class_Code
JOIN Company_Security_Type d on a.Security_Type = d.Security_Type
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-16 : 10:14:24
Answered here ;-

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=104906
Go to Top of Page
   

- Advertisement -