Login | Sign Up
 
  Search  



Site Map
 
HomeMy PagesMy ProfileMy MessagesMy FriendsMore MembersMy GroupsView GroupMore GroupsMy PurchasesAppsS3 AppsS3 FinancialsS3 HR/PayrollS3 ProcurementS3 Supply ChainM3 AppsEnterprise Asset Management Manufacturing OperationsFinancialsBPM/EPM/LBIDesign StudioEnterprise Reporting (Crystal)Microsoft Add-InsProcessFlow / BCISmart NotificationSmart OfficeTechDatabase ERDsData DictionaryApplication SecurityDevelopmentLawson 4GL Quick ReferenceDesign StudioDatabaseDB2OracleSQL ServerEnvironmentiSeriesUnixAIXWindowsLogan/IOSLSF 9M3 System Foundation PortalERDsDocumentationTips & TricksForumsJobsLawsonGuruLawsonGuru LetterLawsonGuru BlogWorthwhile ReadingLawson in the NewsUser RegistrationStoreStore AdminMy PurchasesStore FAQsSearchEngage Publish Search IndexerSearch ResultsSearch TipsArticlesAboutJohnContentUser ManagerBulk User ManagerBackupsMonitorVenexusVenexus Web ControlsViewArticleSignUp!LoginAdminSite SettingsTabsSecurity RolesUser AccountsVendorsSite LogBulk EmailFile ManagerRecycle BinLog ViewerSkinsLanguagesSite WizardAuthenticationSolutionsPageBlaster

Top 10 Posters
 
Tips on Using the LawsonGuru ForumsMaximize

LawsonGuru ForumsMinimize
SQL question on APINVOICE, APDISTRIB, APPAYMENT
Last Post 11/01/2007 10:15 AM by John Henley. 1 Replies.
Printer Friendly
Sort:
PrevPrevNextNext
To join the discussion you need to register first. (Registration is free!) If you are already a registered user please login to join the discussion.
AuthorMessages
Karl KempUser is Offline
Private
Private
Basic Member (29 points)
Basic Member
Posts:20
Karl Kemp

Send Message: Send Private Message

--
11/01/2007 09:45 AM  
I am trying to write a query that will return APINVOICE, APDISTRIB, APVENMAST, and APPAYMENT information.

Basically the user wants the Paid invoice detail information including vendor name and check number & date.

I created the following query but it doesn't seem to completely work the way I would like it to do. It pulls the same invoice & distrib twice for each combination. In other words, if there is a single invoice with 2 distribution records, instead of the query returning 2 records it actually returns 4. this seems to happen when I include the part of the query where I add the logic to pull the appayment info (check date, number). If I remove the appayment stuff, the query seems to work fine.

Any thoughts?

select p.company, a.vendor, a.vendor_vname, p.invoice, p.invoice_dte, p.due_date, p.create_date,
p.distrib_date, d.dis_acct_unit, d.dis_account, y.bank_chk_amt, d.to_base_amt, y.check_date, y.trans_nbr
from uabhssd.apvenmast a,
uabhssd.apinvoice p,
uabhssd.appayment y,
uabhssd.apdistrib d
where (
p.company = d.company and
p.vendor = d.vendor and
p.invoice = d.invoice and
a.vendor = d.vendor and
y.company = p.company and
y.vendor = p.vendor and
y.invoice = p.invoice and
p.tran_paid_amt <> 0
)
John HenleyUser is Offline
Private
Private
Veteran Member (3333 points)
Veteran Member
Posts:1677
John Henley

Send Message: Send Private Message

--
11/01/2007 10:15 AM  
Hi Karl, the problem is that you are doing an "inner join" (by default), which returns a combined row for all joined tables. You need to use an outer join to achieve the desired result. The syntax for outer joins differs from database vendor to database vendor, but if you're using Oracle you could probably do something like this (also, you were missing some fields in the joins):

select api.company, ven.vendor, ven.vendor_vname, api.invoice, api.invoice_dte, api.due_date, api.create_date,
api.distrib_date, apd.dis_acct_unit, apd.dis_account, app.bank_chk_amt, apd.to_base_amt, app.check_date, app.trans_nbr
from
uabhssapd.apinvoice api,
uabhssapd.appayment app,
uabhssapd.apdistrib apd,
uabhssapd.apvenmast ven
where (
api.company = apd.company (+) and
api.vendor = apd.vendor (+) and
api.invoice = apd.invoice (+) and
api.suffix = apd.suffix (+) and
api.cancel_seq = apd.cancel_seq (+) and
ven.vendor_group = api.vendor_group (+) and
ven.vendor = api.vendor (+) and
app.company = api.company (+) and
app.vendor = api.vendor (+) and
app.invoice = api.invoice (+) and
app.suffix = api.suffix (+) and
app.cancel_seq = api.cancel_seq (+) and
api.tran_paid_amt <> 0
)

Thanks for using the LawsonGuru.com forums!

John
To join the discussion you need to register first. (Registration is free!) If you are already a registered user please login to join the discussion.

Active Forums 4.1
Forum Postings...Minimize
RE: Modifying HTML in 9.0
07/03/2009 11:03 AM
I usually copy and paste the description of the pa

Security Administrator won't connect.
07/03/2009 10:36 AM
Once in a while, security administrator won't conn

RE: Two Questions:
07/03/2009 10:07 AM
what programs are doing this?

RE: Lawson Support - Staffing Question
07/02/2009 09:02 PM
The documentation library from Lawson, the support

RE: User 'lawson' SSO Password
07/02/2009 02:26 PM
Matt - thank you for the information. I'll change

ed810 not pulling tax
07/02/2009 12:40 PM
we are currently 8.03 sitting on 9.0lsf and use Gh

RE: Crystal for Financial Reporting
07/02/2009 11:17 AM
However, it is only for summary accounting units,

RE: Sarbox Compliance
07/02/2009 08:40 AM
John, We piloted the security dashboard with AV

RE: Work file paths
07/01/2009 05:04 PM
"We have deleted the job going to the wrong direct

RE: CSV Export
07/01/2009 02:00 PM
Are you using portal? If so run the wh130 to crea

Home  |  Tips & Tricks  |  Forums  |  Jobs  |  Store  |  About