SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to add a 3rd table to this join
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AdamWest
Constraint Violating Yak Guru

USA
351 Posts

Posted - 08/29/2013 :  18:36:45  Show Profile  Reply with Quote
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#

Edited by - AdamWest on 08/29/2013 19:00:23

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 08/29/2013 :  23:53:49  Show Profile  Reply with Quote
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

USA
351 Posts

Posted - 08/30/2013 :  14:39:26  Show Profile  Reply with Quote

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

India
52309 Posts

Posted - 08/31/2013 :  05:01:23  Show Profile  Reply with Quote

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 


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000