https://generalledger-gl.blogspot.com/2017/10/date-wise-trial-balance-on-particular.html
select gcc.SEGMENT4,
--H.JE_CATEGORY,H.JE_SOURCE,
--h.je_header_id, h.name,
L.EFFECTIVE_DATE,
----------------------------------------
(select
--hh.JE_CATEGORY,hh.JE_SOURCE,
--hh.je_header_id, hh.name,
--LL.ENTERED_DR, LL.ENTERED_CR, (nvl(LL.ENTERED_DR,0) - nvl(LL.ENTERED_CR,0)) BAL
nvl(SUM(nvl(LL.ACCOUNTED_DR, 0) - nvl(LL.ACCOUNTED_CR, 0)), 0)
from gl_je_headers hh, gl_je_lines ll, gl_code_combinations gccc
where 1 = 1
and hh.je_header_id = LL.je_header_id
and LL.code_combination_id = gccc.code_combination_id
and hh.LEDGER_ID = ll.LEDGER_ID
and gccc.SEGMENT4 = gcc.SEGMENT4
--and hh.default_effective_date<='31-OCT-15'
--and hh.period_name='OCT-15'
AND trunc(LL.EFFECTIVE_DATE) < trunc(L.EFFECTIVE_DATE)
--and hh.je_category='Purchase Invoices'
and gccc.segment4 = &ACCOUNT
--AND hh.CURRENCY_CODE='PKR'
AND hh.LEDGER_ID = &LEDGER
and hh.STATUS = 'P'
and ll.STATUS = 'P'
and hh.Actual_flag = 'A'
--AND hh.JE_SOURCE='Payables'
--AND hh.JE_CATEGORY='Purchase Invoices'
--GROUP BY LL.EFFECTIVE_DATE
--group by ll.EFFECTIVE_DATE
) OPENING_BALANCE_XLA,
-----------------------------------------------
--L.ENTERED_DR, L.ENTERED_CR, (nvl(L.ENTERED_DR,0) - nvl(L.ENTERED_CR,0)) BAL
SUM(NVL(L.ACCOUNTED_DR, 0)) DATE_DR,
SUM(NVL(L.ACCOUNTED_CR, 0)) DATE_CR
/*,SUM(nvl(L.ENTERED_DR,0) - nvl(L.ENTERED_CR,0)) BAL*/
,
(select
--hh.JE_CATEGORY,hh.JE_SOURCE,
--hh.je_header_id, hh.name,
--LL.ENTERED_DR, LL.ENTERED_CR, (nvl(LL.ENTERED_DR,0) - nvl(LL.ENTERED_CR,0)) BAL
nvl(SUM(nvl(LL.ACCOUNTED_DR, 0) - nvl(LL.ACCOUNTED_CR, 0)), 0)
from gl_je_headers hh, gl_je_lines ll, gl_code_combinations gccc
where 1 = 1
and hh.je_header_id = LL.je_header_id
and LL.code_combination_id = gccc.code_combination_id
and hh.LEDGER_ID = ll.LEDGER_ID
and gccc.SEGMENT4 = gcc.SEGMENT4
--and hh.default_effective_date<='31-OCT-15'
--and hh.period_name='OCT-15'
AND trunc(LL.EFFECTIVE_DATE) < trunc(L.EFFECTIVE_DATE)
--and hh.je_category='Purchase Invoices'
and gccc.segment4 = &ACCOUNT
--AND hh.CURRENCY_CODE='PKR'
AND hh.LEDGER_ID = &LEDGER
and hh.STATUS = 'P'
and ll.STATUS = 'P'
and hh.Actual_flag = 'A'
--AND hh.JE_SOURCE='Payables'
--AND hh.JE_CATEGORY='Purchase Invoices'
--GROUP BY LL.EFFECTIVE_DATE
--group by ll.EFFECTIVE_DATE
) + SUM(NVL(L.ACCOUNTED_DR, 0)) - SUM(NVL(L.ACCOUNTED_CR, 0)) ENDING_BALANCE
from gl_je_headers h, gl_je_lines l, gl_code_combinations gcc
where 1 = 1
and h.je_header_id = l.je_header_id
and l.code_combination_id = gcc.code_combination_id
and h.LEDGER_ID = l.LEDGER_ID
--and h.default_effective_date<='31-OCT-15'
--and h.period_name='OCT-15'
AND trunc(L.EFFECTIVE_DATE) BETWEEN &FROM_DATE AND &TO_DATE
--and h.je_category='Purchase Invoices'
and gcc.segment4 = &ACCOUNT
--AND H.CURRENCY_CODE='PKR'
AND H.LEDGER_ID = &LEDGER
and H.STATUS = 'P'
and l.STATUS = 'P'
and H.Actual_flag = 'A'
--AND H.JE_SOURCE='Payables'
--AND H.JE_CATEGORY='Purchase Invoices'
GROUP BY L.EFFECTIVE_DATE, gcc.SEGMENT4
--GROUP BY H.JE_CATEGORY,H.JE_SOURCE
ORDER BY L.EFFECTIVE_DATE
PLSQL Query to Get Date wise Trial Balance on Particular Account
select gcc.SEGMENT4,
--H.JE_CATEGORY,H.JE_SOURCE,
--h.je_header_id, h.name,
L.EFFECTIVE_DATE,
----------------------------------------
(select
--hh.JE_CATEGORY,hh.JE_SOURCE,
--hh.je_header_id, hh.name,
--LL.ENTERED_DR, LL.ENTERED_CR, (nvl(LL.ENTERED_DR,0) - nvl(LL.ENTERED_CR,0)) BAL
nvl(SUM(nvl(LL.ACCOUNTED_DR, 0) - nvl(LL.ACCOUNTED_CR, 0)), 0)
from gl_je_headers hh, gl_je_lines ll, gl_code_combinations gccc
where 1 = 1
and hh.je_header_id = LL.je_header_id
and LL.code_combination_id = gccc.code_combination_id
and hh.LEDGER_ID = ll.LEDGER_ID
and gccc.SEGMENT4 = gcc.SEGMENT4
--and hh.default_effective_date<='31-OCT-15'
--and hh.period_name='OCT-15'
AND trunc(LL.EFFECTIVE_DATE) < trunc(L.EFFECTIVE_DATE)
--and hh.je_category='Purchase Invoices'
and gccc.segment4 = &ACCOUNT
--AND hh.CURRENCY_CODE='PKR'
AND hh.LEDGER_ID = &LEDGER
and hh.STATUS = 'P'
and ll.STATUS = 'P'
and hh.Actual_flag = 'A'
--AND hh.JE_SOURCE='Payables'
--AND hh.JE_CATEGORY='Purchase Invoices'
--GROUP BY LL.EFFECTIVE_DATE
--group by ll.EFFECTIVE_DATE
) OPENING_BALANCE_XLA,
-----------------------------------------------
--L.ENTERED_DR, L.ENTERED_CR, (nvl(L.ENTERED_DR,0) - nvl(L.ENTERED_CR,0)) BAL
SUM(NVL(L.ACCOUNTED_DR, 0)) DATE_DR,
SUM(NVL(L.ACCOUNTED_CR, 0)) DATE_CR
/*,SUM(nvl(L.ENTERED_DR,0) - nvl(L.ENTERED_CR,0)) BAL*/
,
(select
--hh.JE_CATEGORY,hh.JE_SOURCE,
--hh.je_header_id, hh.name,
--LL.ENTERED_DR, LL.ENTERED_CR, (nvl(LL.ENTERED_DR,0) - nvl(LL.ENTERED_CR,0)) BAL
nvl(SUM(nvl(LL.ACCOUNTED_DR, 0) - nvl(LL.ACCOUNTED_CR, 0)), 0)
from gl_je_headers hh, gl_je_lines ll, gl_code_combinations gccc
where 1 = 1
and hh.je_header_id = LL.je_header_id
and LL.code_combination_id = gccc.code_combination_id
and hh.LEDGER_ID = ll.LEDGER_ID
and gccc.SEGMENT4 = gcc.SEGMENT4
--and hh.default_effective_date<='31-OCT-15'
--and hh.period_name='OCT-15'
AND trunc(LL.EFFECTIVE_DATE) < trunc(L.EFFECTIVE_DATE)
--and hh.je_category='Purchase Invoices'
and gccc.segment4 = &ACCOUNT
--AND hh.CURRENCY_CODE='PKR'
AND hh.LEDGER_ID = &LEDGER
and hh.STATUS = 'P'
and ll.STATUS = 'P'
and hh.Actual_flag = 'A'
--AND hh.JE_SOURCE='Payables'
--AND hh.JE_CATEGORY='Purchase Invoices'
--GROUP BY LL.EFFECTIVE_DATE
--group by ll.EFFECTIVE_DATE
) + SUM(NVL(L.ACCOUNTED_DR, 0)) - SUM(NVL(L.ACCOUNTED_CR, 0)) ENDING_BALANCE
from gl_je_headers h, gl_je_lines l, gl_code_combinations gcc
where 1 = 1
and h.je_header_id = l.je_header_id
and l.code_combination_id = gcc.code_combination_id
and h.LEDGER_ID = l.LEDGER_ID
--and h.default_effective_date<='31-OCT-15'
--and h.period_name='OCT-15'
AND trunc(L.EFFECTIVE_DATE) BETWEEN &FROM_DATE AND &TO_DATE
--and h.je_category='Purchase Invoices'
and gcc.segment4 = &ACCOUNT
--AND H.CURRENCY_CODE='PKR'
AND H.LEDGER_ID = &LEDGER
and H.STATUS = 'P'
and l.STATUS = 'P'
and H.Actual_flag = 'A'
--AND H.JE_SOURCE='Payables'
--AND H.JE_CATEGORY='Purchase Invoices'
GROUP BY L.EFFECTIVE_DATE, gcc.SEGMENT4
--GROUP BY H.JE_CATEGORY,H.JE_SOURCE
ORDER BY L.EFFECTIVE_DATE
No comments:
Post a Comment