Login
Register
Search
Home
Forums
Jobs
LawsonGuru
LawsonGuru Letter
LawsonGuru Blog
Worthwhile Reading
Infor Lawson News Feed
Store
Store FAQs
About
Forums
Integration / Customization
S3 Customization/Development
SQL question on APINVOICE, APDISTRIB, APPAYMENT
Home
Forums
Jobs
LawsonGuru
LawsonGuru Letter
LawsonGuru Blog
Worthwhile Reading
Infor Lawson News Feed
Store
Store FAQs
About
Who's On?
Membership:
Latest:
TomV
Past 24 Hours:
1
Prev. 24 Hours:
2
Overall:
5186
People Online:
Visitors:
177
Members:
0
Total:
177
Online Now:
New Topics
Lawson Landmark
LPL INSTR Functions
4/5/2024 8:32 PM
I'm writing a simple report using the Create R
Infor SCM
Translating 856 to get the ~ REF^CN^ field
4/3/2024 8:24 PM
We are trying to get the tracking number which is
IPA/ProcessFlow
Sample XML file create Flow
4/3/2024 3:43 PM
Hello everyone, I am new to creating XML files
Lawson S3 HR/Payroll/Benefits
bn105 error message
3/26/2024 6:40 PM
I need to change some of the set ups in our Life I
IPA/ProcessFlow
IPA executing Job
3/13/2024 7:08 PM
New to the IPA world and was wondering, can an IPA
Lawson S3 HR/Payroll/Benefits
Life Age Reduction on benefits plans
3/12/2024 7:15 PM
For our optional life we have an age based coverag
Lawson S3 HR/Payroll/Benefits
BN53.1 Add-In
3/7/2024 3:31 PM
We are migrating to Solstice. They require a
Lawson Business Intelligence/Reporting/Crystal
Domain Name Change
3/5/2024 7:45 PM
Our domain name needs to change and was hoping I c
S3 Customization/Development
Cobol calling Shell Script
2/29/2024 1:27 PM
Has anyone created or modified a Lawson Cobol prog
Infor ION
ION vs IPA
2/29/2024 1:24 AM
We had a person new to Lawson and Infor go to Info
Top Forum Posters
Name
Points
Greg Moeller
4184
David Williams
3349
JonA
3288
Kat V
2984
Woozy
1973
Jimmy Chiu
1883
Kwane McNeal
1437
Ragu Raghavan
1348
Roger French
1311
mark.cook
1244
Forums
Unanswered
Active Topics
Most Liked
Most Replies
Search Forums
Search
Advanced Search
Topics
Posts
Prev
Next
Forums
S3 Customization/Development
SQL question on APINVOICE, APDISTRIB, APPAYMENT
Sort:
Oldest First
Most Recent First
You are not authorized to post a reply.
Author
Messages
Karl Kemp
Basic Member
Posts: 20
11/1/2007 12:45 PM
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 Henley
Senior Member
Posts: 3348
11/1/2007 1:15 PM
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
)
Chesca
Veteran Member
Posts: 490
1/28/2016 7:52 PM
John, using the SQL statement provided, could you help with SQL statement just to get any vendors that had payments of 600 or more in the year?
You are not authorized to post a reply.