Thursday, July 7, 2011

AP Trail Balances SQL Query for 11i

SELECT alb.invoice_id invoice_id,inv.INVOICE_NUM,inv.DESCRIPTION INV_DESCRIPTION,
alb.vendor_id vendor_id,pv.SEGMENT1 Vendor#,pv.VENDOR_NAME,
alb.code_combination_id code_combination_id,
SUM(ae_invoice_amount) invoice_amount,
SUM (alb.accounted_cr) - SUM (alb.accounted_dr) remaining_amount,
alb.set_of_books_id set_of_books_id,
alb.org_id org_id,
GCC.SEGMENT1,GCC.SEGMENT2,GCC.SEGMENT3,
INV.INVOICE_TYPE_LOOKUP_CODE,INV.INVOICE_DATE,INV.ATTRIBUTE5 Status,apt.NAME Terms
FROM ap_liability_balance alb,
PO_VENDORS PV,AP_INVOICES_ALL INV,
GL_CODE_COMBINATIONS GCC,
 AP_TERMS apt
WHERE PV.VENDOR_ID=alb.VENDOR_ID
and INV.INVOICE_ID=alb.INVOICE_ID
and alb.CODE_COMBINATION_ID=gcc.CODE_COMBINATION_ID
and apt.TERM_ID=INV.TERMS_ID
AND alb.ORG_ID =:org_id 
and trunc(accounting_date) <=:Date1
GROUP BY alb.invoice_id, alb.code_combination_id, alb.vendor_id, alb.set_of_books_id, alb.org_id ,
pv.SEGMENT1,pv.VENDOR_NAME,inv.INVOICE_NUM,inv.DESCRIPTION,GCC.SEGMENT1,GCC.SEGMENT2,GCC.SEGMENT3,
INV.INVOICE_TYPE_LOOKUP_CODE,INV.INVOICE_DATE,INV.ATTRIBUTE5,apt.NAME
HAVING SUM (accounted_cr) <> SUM (accounted_dr)

2 comments:

  1. Hi Mazeed,

    Thanks for the valuable information,

    Please can you provide same Trial balance sql query for R12.

    Thanks and Regards,
    Muthu
    upmuthukumar@gmail.com

    ReplyDelete
  2. Posted R12 Query...here ...

    http://technooracleerp.blogspot.com/2012/06/ap-trail-balances-sql-query-for-r12.html

    ReplyDelete