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
 Query: Two columns with same data

Author  Topic 

MariaPiquer
Starting Member

1 Post

Posted - 2008-05-13 : 22:26:20
Hi,
I have 3 tables:
Table SLA: SLA_code, SLA_name
Table industry: Industry_code, Industry_name
Table14: SLA_code_origin, SLA_code_destination, Industry_code, Freq

I would like to query to get in one table:
SLA_name for DESTINATION, Industry_name, Freq

Note: SLA_code contains the same codes as SLA_code_origin and SLA_code_destination. All are the same codes in column oringin means the From point and colum destination the To point.

How can I query to get the Freq and Industry for those destination SLAs?

I have make a relationship between:
Table SLA.SLA_code with Table14.SLA_code_destination and
Table_industry.Industry_code with Table14.Industry_code

But I am not sure if just a
SELECT SLA.SLA_name, Industry.Industry_name, Table14.Freq
FROM SLA, Industry, Table14
would select the SLA_destination and not the SLA_origin.

Thanks very much in advance,

Maria

ranganath
Posting Yak Master

209 Posts

Posted - 2008-05-14 : 00:46:58
Hi,

Try with this

Select S.SLA_name AS 'DESTINATION', I.Industry_name, T.Freq
From SLA S
Inner Join Table14 T on T.SLA_code_destination = S.SLA_code_destination
Inner Join industry I on I.Industry_code = T.Industry_code
Go to Top of Page
   

- Advertisement -