How is the Beginning Balance in the Trial blanace being calculated?

I'm trying to build a consilidated trial balance report using an external BI solution (Qlik) by querrying the SQL database of Sage (GL_DetailPosting)

Credit and Debit amounts of the current period are wokring perfectly, but i'm not able to figure out how the Begining balance is being calculated..

For Current Assets i took all transactions before that period and it matched, once i reach the revenue it would'nt match.

Should every account category have a different time period for the beginning balance ?