Tuesday, 4 February 2025

Oracle SQL Query to get the GL Account Balances by Segments.

 Here is the sample SQL Query to get the GL Account Balances by Segments.

Please note this is the sample query, modify accordingly as per your requirements.


SELECT 

  gcc.SEGMENT1 || '.' || gcc.SEGMENT2 as ACCOUNT,

  gb.PERIOD_NAME,

  gb.BEGIN_BALANCE_DR - gb.BEGIN_BALANCE_CR as OPENING_BALANCE,

  gb.PERIOD_NET_DR - gb.PERIOD_NET_CR as PERIOD_MOVEMENT,

  gb.END_BALANCE_DR - gb.END_BALANCE_CR as CLOSING_BALANCE

FROM GL_BALANCES gb

     GL_CODE_COMBINATIONS gcc 

WHERE gb.CODE_COMBINATION_ID = gcc.CODE_COMBINATION_ID

AND   gb.PERIOD_NAME = :P_PERIOD_NAME;