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
 How to add a 3rd table to this join

Author  Topic 

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2013-08-29 : 18:36:45
The following code works fine.
But I need to add that we only want part# that have a reporting code that is, are not blank in this table "Audia"
IAPRT# would join on the other prt# and then we want this col added to the output: IARCC9
and then we need to sort by that as well.

select ItQty#,IhDocd,ItPRT# from pklib.Fileout1 a
join astdta.icEct1 b on
b.CtCom#= a.ItCom# and

b.CtCtr# = ' ' and

b.CtPrt# =a.ItPrt#
order by a.ItPRT#

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-08-29 : 23:53:49
which is the field that stors reporting code? Is it in Audia table?
based on your explanation it would be something like


select ItQty#,IhDocd,ItPRT#,IARCC9
from pklib.Fileout1 a
join astdta.icEct1 b on
b.CtCom#= a.ItCom# and

b.CtCtr# = ' ' and

b.CtPrt# =a.ItPrt#
join Audia ad
on ad.[prt#] = a.IAPrt#
where <reportingcode field here> > ''
order by a.ItPRT#


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2013-08-30 : 14:39:26

Ok thanks holy man,
i need one thing. "ad.IARCC9 from astdta.audia " this line i added but it does not compile. I need the field from the last table into the output.
* i added its not working. i need that col in the output. it's all based on that col. which is the customer name.


select ItQty#,IhDocd,ItPRT# from pklib.Fileout1 a
ad.IARCC9 from astdta.audia *
join astdta.icEct1 b on

b.CtCom#= a.ItCom# and

b.CtCtr# = ' ' and

b.CtPrt# =a.ItPrt#
join astdta.Audia ad
on ad.IAprt# = a.ItPrt#
where ad.IARCC9 > ''
order by ad.IARCC9





quote:
Originally posted by visakh16

which is the field that stors reporting code? Is it in Audia table?
based on your explanation it would be something like


select ItQty#,IhDocd,ItPRT#,IARCC9
from pklib.Fileout1 a
join astdta.icEct1 b on
b.CtCom#= a.ItCom# and

b.CtCtr# = ' ' and

b.CtPrt# =a.ItPrt#
join Audia ad
on ad.[prt#] = a.IAPrt#
where <reportingcode field here> > ''
order by a.ItPRT#


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-08-31 : 05:01:23
[code]
select ItQty#,IhDocd,ItPRT#,ad.IARCC9
from pklib.Fileout1 a
join astdta.icEct1 b on

b.CtCom#= a.ItCom# and

b.CtCtr# = ' ' and

b.CtPrt# =a.ItPrt#
join astdta.Audia ad
on ad.IAprt# = a.ItPrt#
where ad.IARCC9 > ''
order by ad.IARCC9
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -