1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] SQL Query works for current month but messes up for prior months

Discussão em 'Outras Linguagens' iniciado por Stack, Agosto 12, 2021.

  1. Stack

    Stack Membro Participativo

    I am having trouble with the following query. It is pulling in the correct amounts for July but is off around 2mm in the prior months and has more occurrences than acutal in prior months vs what I am expecting. I am trying to locate the source of the issue.This query is pulling an account and the GL items and amounts that hit over the past 6 months.

    Select
    gad.ledger_name,
    gad.company_code ,
    gad.location_code ,
    gad.cost_center ,
    gad.account_number ,
    gad.account_name,
    gad.product_code,
    gad.channel_code ,
    gad.journal_name ,
    gad.line_description,
    gad.gl_posted_date,
    gad.currency,
    gad.je_source ,
    gad.je_category ,
    gad.effective_date ,
    gad.created_by,
    gad.invoice_num ,
    gad.invoice_id ,
    gad.invoice_date ,
    gad.vendor_name ,
    gad.vendor_number ,
    gad.invoice_image ,
    gad.po_number ,
    gad.po_requestor ,
    gad.period_name,
    gad.amount,
    gad.project_code,
    rsea.region,
    rsea.sub_region
    from wbr_global.gl_ap_details gad
    left join wbr_global.raw_station_extended_attribute rsea on gad.location_code = rsea.location_code
    where gad.ledger_name = 'Amazon.com, Inc.'
    and cost_center in ('1172')
    and gad.account_number = '60820'
    and to_date(gad.period_name,'MON-YY') > getdate() - 186


    Here is the output summary of actuals in the GL vs the query. [​IMG]

    Continue reading...

Compartilhe esta Página