Monday, 4 November 2013

Query to get General Ledger Balance Details

SELECT   gb.period_name "Period Name"
        ,gb.period_year "Period Year"
        ,gb.period_num "Period Num"
        ,gb.set_of_books_id "SOB ID"
        , gcc.segment1 || '-' || gcc.segment2 || '-' || gcc.segment3 || '-' || gcc.segment4 "Account"
        ,gb.currency_code "Currency"
        ,SUM(gb.period_net_dr) "Period Net Dr"
        ,SUM(gb.period_net_cr) "Period Net Cr"
        ,SUM( (gb.period_net_dr - gb.period_net_cr) ) "PTD"
    FROM gl_balances gb
        ,gl_code_combinations gcc
   WHERE gb.set_of_books_id = 1 AND gb.currency_code = 'CAD' AND gcc.segment4 = '13110' AND gb.code_combination_id = gcc.code_combination_id
GROUP BY gb.period_name
        ,gb.period_year
        ,gb.period_num
        ,gb.set_of_books_id
        , gcc.segment1 || '-' || gcc.segment2 || '-' || gcc.segment3 || '-' || gcc.segment4
        ,gb.currency_code
ORDER BY gb.period_year
        ,gb.period_num

No comments:

Post a Comment