Query causing tempdb size > 50G

  • Hi,

    We have a query that causes the tempdb to grow beyond 50G and the query is still not complete and we have to kill it.

    The 2 tables from which the query is retrieiving data have around 7.9 million rows each.

    Since the query doesn't complete, I had to resort to Display Estimated Execution Plan but it is not of much help.

    What could be the reason behind tempdb going to 50G+?

    RSingh

  • How many rows does your query update?

    What is the size of each line (sum of DATALENGTH for all columns)?

    Is there any chance of CROSS JOIN for those tables?

    It typically happens when you don't have proper indexes or select all (or the most) records from tables.

    If it happens it will create hash table in tempdb with 7.9E+6 * 7.9E+6 ~ 6E+13 records. Each record will contain all columns from both tables mentioned in SELECT. If you use "SELECT * " it will sum the sizes.

    Pretty much, I would say.

    If every records holds just 10 bytes (I doubt it) it will create a table with size 1200 TB.

    _____________
    Code for TallyGenerator

  • Could you please post the

    * SQL query

    * Table definitions

    * Examples of some data in the tables

    ?

    Sergiy's correct though, SQL might be creating a temporary workspace to perform the joining of the tables. Perhaps you do not have enough indices, or, as Sergiy said, are selecting too many columns. With the above information we can help you either recraft the SQL code or create appropriate covering indices. If it's a simple join and this is a query you'll perform often then it may pay to create an indexed view - but this depends also on how often you update the tables, etc.

  • Thanks for the reply.

    Here is the DDL for the important tables involved:

    ================================================================================

    CREATE TABLE [dbo].[GL_Star_Facts2006](

     [AccountID] [nchar](20) NOT NULL,

     [BusinessUnitID] [nchar](20) NOT NULL,

     [CompanyNumberID] [nchar](20) NOT NULL,

     [DateID] [bigint] NOT NULL,

     [FactsDetailID] [nchar](20) NOT NULL,

     [FiscalYearID] [nchar](20) NOT NULL,

     [LedgerID] [nchar](20) NOT NULL,

     [SubLedgerID] [nchar](20) NOT NULL,

     [SourceID] [int] NOT NULL,

     [AID] [nchar](8) NOT NULL,

     [FiscalYear] [int] NOT NULL,

     [Account] [nchar](15) NOT NULL,

     [LedgerTypeCode] [nchar](2) NOT NULL,

     [Object] [nchar](6) NOT NULL,

     [Subsidiary] [nchar](8) NOT NULL,

     [CompanyNumber] [nchar](5) NOT NULL,

     [BusinessUnitCode] [nchar](12) NOT NULL,

     [SubLedger] [nchar](8) NOT NULL,

     [SubLedgerType] [nchar](1) NOT NULL,

     [CurrentMTD] [decimal](20, 7) NOT NULL,

     [CurrentYTD] [decimal](20, 7) NOT NULL,

     [PriorYearCloseBalance] [decimal](20, 7) NOT NULL,

     [NetPosting01] [decimal](20, 7) NOT NULL,

     [Balance01] [decimal](20, 7) NOT NULL,

     [NetPosting02] [decimal](20, 7) NOT NULL,

     [Balance02] [decimal](20, 7) NOT NULL,

     [NetPosting03] [decimal](20, 7) NOT NULL,

     [Balance03] [decimal](20, 7) NOT NULL,

     [NetPosting04] [decimal](20, 7) NOT NULL,

     [Balance04] [decimal](20, 7) NOT NULL,

     [NetPosting05] [decimal](20, 7) NOT NULL,

     [Balance05] [decimal](20, 7) NOT NULL,

     [NetPosting06] [decimal](20, 7) NOT NULL,

     [Balance06] [decimal](20, 7) NOT NULL,

     [NetPosting07] [decimal](20, 7) NOT NULL,

     [Balance07] [decimal](20, 7) NOT NULL,

     [NetPosting08] [decimal](20, 7) NOT NULL,

     [Balance08] [decimal](20, 7) NOT NULL,

     [NetPosting09] [decimal](20, 7) NOT NULL,

     [Balance09] [decimal](20, 7) NOT NULL,

     [NetPosting10] [decimal](20, 7) NOT NULL,

     [Balance10] [decimal](20, 7) NOT NULL,

     [NetPosting11] [decimal](20, 7) NOT NULL,

     [Balance11] [decimal](20, 7) NOT NULL,

     [NetPosting12] [decimal](20, 7) NOT NULL,

     [Balance12] [decimal](20, 7) NOT NULL,

     [NetPosting13] [decimal](20, 7) NOT NULL,

     [Balance13] [decimal](20, 7) NOT NULL,

     [NetPosting14] [decimal](20, 7) NOT NULL,

     [Balance14] [decimal](20, 7) NOT NULL,

     [RequestedBudget] [decimal](20, 7) NOT NULL,

     [ApprovedBudget] [decimal](20, 7) NOT NULL,

     [OriginalBeginningBudget] [decimal](20, 7) NOT NULL,

     [CurrencyCodeFrom] [nchar](3) NOT NULL,

     [CurrencyCodeIn] [nchar](3) NOT NULL,

     [Source] [nchar](20) NOT NULL,

     [ITDPriorYearCloseBalance] [decimal](20, 7) NOT NULL,

     [ITDBalance01] [decimal](20, 7) NOT NULL,

     [ITDBalance02] [decimal](20, 7) NOT NULL,

     [ITDBalance03] [decimal](20, 7) NOT NULL,

     [ITDBalance04] [decimal](20, 7) NOT NULL,

     [ITDBalance05] [decimal](20, 7) NOT NULL,

     [ITDBalance06] [decimal](20, 7) NOT NULL,

     [ITDBalance07] [decimal](20, 7) NOT NULL,

     [ITDBalance08] [decimal](20, 7) NOT NULL,

     [ITDBalance09] [decimal](20, 7) NOT NULL,

     [ITDBalance10] [decimal](20, 7) NOT NULL,

     [ITDBalance11] [decimal](20, 7) NOT NULL,

     [ITDBalance12] [decimal](20, 7) NOT NULL,

     [ITDBalance13] [decimal](20, 7) NOT NULL,

     [ITDBalance14] [decimal](20, 7) NOT NULL,

     [InsertIndicator] [int] NOT NULL,

     [InsertDate] [datetime] NOT NULL,

     [ChangeIndicator] [int] NOT NULL,

     [ChangeDate] [datetime] NOT NULL,

     [DeleteIndicator] [int] NOT NULL,

     [DeleteDate] [datetime] NOT NULL,

     [PurgeDate] [datetime] NOT NULL,

     CONSTRAINT [PK_GL_Star_Facts2006] PRIMARY KEY CLUSTERED

    (

     [AID] ASC,

     [SubLedger] ASC,

     [SubLedgerType] ASC,

     [FiscalYear] ASC,

     [LedgerTypeCode] ASC,

     [CurrencyCodeFrom] ASC,

     [CurrencyCodeIn] ASC,

     [SourceID] ASC

    )WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF, FILLFACTOR = 80) ON [GLDATA]

    ) ON [GLDATA]

    END

    GO

    IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts2006]') AND name = N'IX_Account')

    CREATE NONCLUSTERED INDEX [IX_Account] ON [dbo].[GL_Star_Facts2006]

    (

     [Account] ASC,

     [SourceID] ASC

    )WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [GLDATA]

    GO

    IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts2006]') AND name = N'IX_Balances')

    CREATE NONCLUSTERED INDEX [IX_Balances] ON [dbo].[GL_Star_Facts2006]

    (

     [SourceID] ASC,

     [LedgerTypeCode] ASC,

     [BusinessUnitCode] ASC,

     [Account] ASC

    )

    INCLUDE ( [Object],

    [Balance01],

    [Balance02],

    [Balance03],

    [Balance04],

    [Balance05],

    [Balance06],

    [Balance07],

    [Balance08],

    [Balance09],

    [Balance10],

    [Balance11],

    [Balance12]) WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [GLDATA]

    GO

    IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts2006]') AND name = N'IX_BusinessUnit')

    CREATE NONCLUSTERED INDEX [IX_BusinessUnit] ON [dbo].[GL_Star_Facts2006]

    (

     [BusinessUnitCode] ASC,

     [SourceID] ASC

    )WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [GLDATA]

    GO

    IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts2006]') AND name = N'IX_Company')

    CREATE NONCLUSTERED INDEX [IX_Company] ON [dbo].[GL_Star_Facts2006]

    (

     [CompanyNumber] ASC,

     [SourceID] ASC

    )WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [GLDATA]

    GO

    IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts2006]') AND name = N'IX_FiscalYear')

    CREATE NONCLUSTERED INDEX [IX_FiscalYear] ON [dbo].[GL_Star_Facts2006]

    (

     [FiscalYear] ASC,

     [SourceID] ASC

    )WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [GLDATA]

    GO

    IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts2006]') AND name = N'IX_LedgerType')

    CREATE NONCLUSTERED INDEX [IX_LedgerType] ON [dbo].[GL_Star_Facts2006]

    (

     [LedgerTypeCode] ASC,

     [SourceID] ASC

    )WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [GLDATA]

    GO

    IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts2006]') AND name = N'IX_SubLedger')

    CREATE NONCLUSTERED INDEX [IX_SubLedger] ON [dbo].[GL_Star_Facts2006]

    (

     [SubLedger] ASC,

     [SubLedgerType] ASC,

     [SourceID] ASC

    )WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [GLDATA]

    GO

    ----------------------------------------------------------------------------------------------

    CREATE TABLE [dbo].[Star_BusinessUnit](

     [BusinessUnitID] [char](20) NOT NULL,

     [SourceID] [int] NOT NULL,

     [BusinessUnitCode] [char](12) NOT NULL,

     [Type] [char](2) NOT NULL,

     [BusinessUnitTypeDescription] [char](30) NOT NULL,

     [BusinessUnit] [char](30) NOT NULL,

     [PostingEditCode] [char](1) NOT NULL,

     [PostingEditCodeDescription] [char](30) NOT NULL,

     [CompanyNumber] [char](5) NOT NULL,

     [AddressNumber] [int] NOT NULL,

     [Category01Code] [char](3) NOT NULL,

     [Category01] [varchar](255) NOT NULL,

     [Category02Code] [char](3) NOT NULL,

     [Category02] [varchar](255) NOT NULL,

     [Category03Code] [char](3) NOT NULL,

     [Category03] [varchar](255) NOT NULL,

     [Category04Code] [char](3) NOT NULL,

     [Category04] [varchar](255) NOT NULL,

     [Category05Code] [char](3) NOT NULL,

     [Category05] [varchar](255) NOT NULL,

     [Category06Code] [char](3) NOT NULL,

     [Category06] [varchar](255) NOT NULL,

     [Category07Code] [char](3) NOT NULL,

     [Category07] [varchar](255) NOT NULL,

     [Category08Code] [char](3) NOT NULL,

     [Category08] [varchar](255) NOT NULL,

     [Category09Code] [char](3) NOT NULL,

     [Category09] [varchar](255) NOT NULL,

     [Category10Code] [char](3) NOT NULL,

     [Category10] [varchar](255) NOT NULL,

     [Category11Code] [char](3) NOT NULL,

     [Category11] [varchar](255) NOT NULL,

     [Category12Code] [char](3) NOT NULL,

     [Category12] [varchar](255) NOT NULL,

     [Category13Code] [char](3) NOT NULL,

     [Category13] [varchar](255) NOT NULL,

     [Category14Code] [char](3) NOT NULL,

     [Category14] [varchar](255) NOT NULL,

     [Category15Code] [char](3) NOT NULL,

     [Category15] [varchar](255) NOT NULL,

     [Category16Code] [char](3) NOT NULL,

     [Category16] [varchar](255) NOT NULL,

     [Category17Code] [char](3) NOT NULL,

     [Category17] [varchar](255) NOT NULL,

     [Category18Code] [char](3) NOT NULL,

     [Category18] [varchar](255) NOT NULL,

     [Category19Code] [char](3) NOT NULL,

     [Category19] [varchar](255) NOT NULL,

     [Category20Code] [char](3) NOT NULL,

     [Category20] [varchar](255) NOT NULL,

     [Category21Code] [char](10) NOT NULL,

     [Category21] [varchar](255) NOT NULL,

     [Category22Code] [char](10) NOT NULL,

     [Category22] [varchar](255) NOT NULL,

     [Category23Code] [char](10) NOT NULL,

     [Category23] [varchar](255) NOT NULL,

     [Category24Code] [char](10) NOT NULL,

     [Category24] [varchar](255) NOT NULL,

     [Category25Code] [char](10) NOT NULL,

     [Category25] [varchar](255) NOT NULL,

     [Category26Code] [char](10) NOT NULL,

     [Category26] [varchar](255) NOT NULL,

     [Category27Code] [char](10) NOT NULL,

     [Category27] [varchar](255) NOT NULL,

     [Category28Code] [char](10) NOT NULL,

     [Category28] [varchar](255) NOT NULL,

     [Category29Code] [char](10) NOT NULL,

     [Category29] [varchar](255) NOT NULL,

     [Category30Code] [char](10) NOT NULL,

     [Category30] [varchar](255) NOT NULL,

     [Source] [char](20) NOT NULL,

     [OwnerReceivableAddress] [int] NOT NULL,

     [County] [char](3) NOT NULL,

     [StateCode] [char](3) NOT NULL,

     [StateCodeDescription] [char](30) NOT NULL,

     [ContractType] [char](4) NOT NULL,

     [CertifiedJobYN] [char](1) NOT NULL,

     [ProjectNumber] [char](12) NOT NULL,

     [PercentComplete] [decimal](20, 7) NOT NULL,

     [CostToComplete] [decimal](20, 7) NOT NULL,

     [PlannedStartDateID] [bigint] NOT NULL,

     [ActualStartDateID] [bigint] NOT NULL,

     [PlannedCompletionDateID] [bigint] NOT NULL,

     [ActualCompletionDateID] [bigint] NOT NULL,

     [FinalPaymentDateID] [bigint] NOT NULL,

     [CostAtCompletion] [decimal](20, 7) NOT NULL,

     [ProfitAtCompletion] [decimal](20, 7) NOT NULL,

     [InsertIndicator] [int] NOT NULL,

     [InsertDate] [datetime] NOT NULL,

     [ChangeIndicator] [int] NOT NULL,

     [ChangeDate] [datetime] NOT NULL,

     [DeleteIndicator] [int] NOT NULL,

     [DeleteDate] [datetime] NOT NULL,

     [PurgeDate] [datetime] NOT NULL,

     CONSTRAINT [PK_Star_BusinessUnit] PRIMARY KEY CLUSTERED

    (

     [BusinessUnitCode] ASC,

     [SourceID] ASC

    )WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF, FILLFACTOR = 90) ON [PRIMARY]

    ) ON [PRIMARY]

    END

    GO

    IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Star_BusinessUnit]') AND name = N'IX_BusinessUnit_Category')

    CREATE NONCLUSTERED INDEX [IX_BusinessUnit_Category] ON [dbo].[Star_BusinessUnit]

    (

     [Category15Code] ASC,

     [Category15] ASC,

     [Category20] ASC,

     [Category21Code] ASC,

     [SourceID] ASC

    )

    INCLUDE ( [BusinessUnitCode],

    [Category20Code]) WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [COMMONDATA]

    GO

     

    --------------------------------------------------------------------------------------------------------

    CREATE TABLE [dbo].[Star_Account](

     [AccountID] [char](20) NOT NULL,

     [SourceID] [int] NOT NULL,

     [AID] [char](8) NOT NULL,

     [Account] [char](15) NOT NULL,

     [AccountDesc] [char](30) NOT NULL,

     [BusinessUnitCode] [char](12) NOT NULL,

     [Company] [char](5) NOT NULL,

     [Object] [char](6) NOT NULL,

     [Subsidiary] [char](8) NOT NULL,

     [LevelOfDetail] [char](1) NOT NULL,

     [PostingEditCode] [char](1) NOT NULL,

     [PostingEditCodeDescription] [char](60) NOT NULL,

     [AccountParent] [char](15) NULL,

     [AccountParentDesc] [char](30) NULL,

     [AccountLOD3] [char](15) NULL,

     [AccountLOD3Desc] [char](30) NULL,

     [AccountLOD4] [char](15) NULL,

     [AccountLOD4Desc] [char](30) NULL,

     [AccountLOD5] [char](15) NULL,

     [AccountLOD5Desc] [char](30) NULL,

     [AccountLOD6] [char](15) NULL,

     [AccountLOD6Desc] [char](30) NULL,

     [AccountLOD7] [char](15) NULL,

     [AccountLOD7Desc] [char](30) NULL,

     [AccountLOD8] [char](15) NULL,

     [AccountLOD8Desc] [char](30) NULL,

     [AccountLOD9] [char](15) NULL,

     [AccountLOD9Desc] [char](30) NULL,

     [Category01Code] [char](3) NOT NULL,

     [Category01] [varchar](255) NOT NULL,

     [Category02Code] [char](3) NOT NULL,

     [Category02] [varchar](255) NOT NULL,

     [Category03Code] [char](3) NOT NULL,

     [Category03] [varchar](255) NOT NULL,

     [Category04Code] [char](3) NOT NULL,

     [Category04] [varchar](255) NOT NULL,

     [Category05Code] [char](3) NOT NULL,

     [Category05] [varchar](255) NOT NULL,

     [Category06Code] [char](3) NOT NULL,

     [Category06] [varchar](255) NOT NULL,

     [Category07Code] [char](3) NOT NULL,

     [Category07] [varchar](255) NOT NULL,

     [Category08Code] [char](3) NOT NULL,

     [Category08] [varchar](255) NOT NULL,

     [Category09Code] [char](3) NOT NULL,

     [Category09] [varchar](255) NOT NULL,

     [Category10Code] [char](3) NOT NULL,

     [Category10] [varchar](255) NOT NULL,

     [Category11Code] [char](3) NOT NULL,

     [Category11] [varchar](255) NOT NULL,

     [Category12Code] [char](3) NOT NULL,

     [Category12] [varchar](255) NOT NULL,

     [Category13Code] [char](3) NOT NULL,

     [Category13] [varchar](255) NOT NULL,

     [Category14Code] [char](3) NOT NULL,

     [Category14] [varchar](255) NOT NULL,

     [Category15Code] [char](3) NOT NULL,

     [Category15] [varchar](255) NOT NULL,

     [Category16Code] [char](3) NOT NULL,

     [Category16] [varchar](255) NOT NULL,

     [Category17Code] [char](3) NOT NULL,

     [Category17] [varchar](255) NOT NULL,

     [Category18Code] [char](3) NOT NULL,

     [Category18] [varchar](255) NOT NULL,

     [Category19Code] [char](3) NOT NULL,

     [Category19] [varchar](255) NOT NULL,

     [Category20Code] [char](3) NOT NULL,

     [Category20] [varchar](255) NOT NULL,

     [Category21Code] [char](10) NOT NULL,

     [Category21] [varchar](255) NOT NULL,

     [Category22Code] [char](10) NOT NULL,

     [Category22] [varchar](255) NOT NULL,

     [Category23Code] [char](10) NOT NULL,

     [Category23] [varchar](255) NOT NULL,

     [Source] [char](20) NOT NULL,

     [InsertIndicator] [int] NOT NULL,

     [InsertDate] [datetime] NOT NULL,

     [ChangeIndicator] [int] NOT NULL,

     [ChangeDate] [datetime] NOT NULL,

     [DeleteIndicator] [int] NOT NULL,

     [DeleteDate] [datetime] NOT NULL,

     [PurgeDate] [datetime] NOT NULL,

     CONSTRAINT [PK_Star_Account] PRIMARY KEY CLUSTERED

    (

     [AID] ASC,

     [SourceID] ASC

    )WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF, FILLFACTOR = 90) ON [COMMONDATA]

    ) ON [COMMONDATA]

    END

    GO

    IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Star_Account]') AND name = N'IX_Object')

    CREATE NONCLUSTERED INDEX [IX_Object] ON [dbo].[Star_Account]

    (

     [Object] ASC

    )

    INCLUDE ( [SourceID],

    [Account]) WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [COMMONDATA]

    GO

    ==================================================================================

    Here is the SQL Query giving us trouble:

    SELECT

      Business_Unit.Category15Code,

      Business_Unit.Category15,

      Business_Unit.Category20,

      Business_Unit.Category21Code,

      CASE

    when ( Business_Unit.Category15Code ) In  ( 'NA','KI','EH','KO','UM','H') then 'NAR'

    when ( Business_Unit.Category20Code ) In  ( 'I','E') then 'ER'

    when ( Business_Unit.Category20Code ) In  ( 'A') then 'AL'

    when ( Business_Unit.Category15Code ) In  ( 'U') then 'UUU'

    when ( Business_Unit.Category15Code ) In  ( 'T') then 'TTT'

    when ( Business_Unit.Category15Code ) In  ( 'HE') then 'HEQ'

    when ( Business_Unit.Category15Code ) In  ( 'E') then 'ELL'

    else 'Other'

    end,

      CASE

    when ( Business_Unit.Category15Code ) In  ( 'NA','KI','EH','KO','UM','H') then 'NAR'

    when ( Business_Unit.Category20Code ) In  ( 'I','E')  then 'ER'

    when ( Business_Unit.Category20Code ) In  ( 'A') then 'AL'

    else 'Other'

    end,

      CASE

    when ( Business_Unit.Category15Code ) In  ( 'U') then 'UUU'

    when ( Business_Unit.Category15Code ) In  ( 'T') then 'TTT'

    when ( Business_Unit.Category15Code ) In  ( 'HE') then 'HEQ'

    when ( Business_Unit.Category15Code ) In  ( 'E') then 'ELL'

    else 'Other'

    end,

      sum(CASE

    when  FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1000' AND '1036') then

    ( Facts.Balance01)

    when  FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1000' AND '1036') then

    ( Facts.Balance02)

    when  FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1000' AND '1036') then

    ( Facts.Balance03)

    when  FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1000' AND '1036') then

    ( Facts.Balance04)

    when  FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1000' AND '1036') then

    ( Facts.Balance05)

    when  FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1000' AND '1036') then

    ( Facts.Balance06)

    when  FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1000' AND '1036') then

    ( Facts.Balance07)

    when  FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1000' AND '1036') then

    ( Facts.Balance08)

    when  FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1000' AND '1036') then

    ( Facts.Balance09)

    when  FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1000' AND '1036') then

    ( Facts.Balance10)

    when  FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1000' AND '1036') then

    ( Facts.Balance11)

    when  FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1000' AND '1036') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1037' AND '1049') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1037' AND '1049') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1037' AND '1049') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1037' AND '1049') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1037' AND '1049') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1037' AND '1049') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1037' AND '1049') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1037' AND '1049') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1037' AND '1049') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1037' AND '1049') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1037' AND '1049') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1037' AND '1049') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1050' AND '1052' or (  Facts.Object ) = '1057') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1050' AND '1052' or (  Facts.Object ) = '1057') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1050' AND '1052' or (  Facts.Object ) = '1057') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1050' AND '1052' or (  Facts.Object ) = '1057') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1050' AND '1052' or (  Facts.Object ) = '1057') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1050' AND '1052' or (  Facts.Object ) = '1057') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1050' AND '1052' or (  Facts.Object ) = '1057') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1050' AND '1052' or (  Facts.Object ) = '1057') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1050' AND '1052' or (  Facts.Object ) = '1057') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1050' AND '1052' or (  Facts.Object ) = '1057') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1050' AND '1052' or (  Facts.Object ) = '1057') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1050' AND '1052' or (  Facts.Object ) = '1057') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) =  '1056' OR (  Facts.Object ) = '1059') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) =  '1056' OR (  Facts.Object ) = '1059') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) =  '1056' OR (  Facts.Object ) = '1059') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) =  '1056' OR (  Facts.Object ) = '1059') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) =  '1056' OR (  Facts.Object ) = '1059') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) =  '1056' OR (  Facts.Object ) = '1059') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) =  '1056' OR (  Facts.Object ) = '1059') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) =  '1056' OR (  Facts.Object ) = '1059') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) =  '1056' OR (  Facts.Object ) = '1059') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) =  '1056' OR (  Facts.Object ) = '1059') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) =  '1056' OR (  Facts.Object ) = '1059') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) =  '1056' OR (  Facts.Object ) = '1059') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) =  '1058') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) =  '1058') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) =  '1058') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) =  '1058') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) =  '1058') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) =  '1058') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) =  '1058') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) =  '1058') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) =  '1058') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) =  '1058') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) =  '1058') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) =  '1058') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) =  '1054') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) =  '1054') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) =  '1054') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) =  '1054') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) =  '1054') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) =  '1054') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) =  '1054') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) =  '1054') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) =  '1054') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) =  '1054') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) =  '1054') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) =  '1054') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1100' AND '1392') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1100' AND '1392') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1100' AND '1392') then 

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1100' AND '1392') then 

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1100' AND '1392') then 

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1100' AND '1392') then 

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1100' AND '1392') then 

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1100' AND '1392') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1100' AND '1392') then 

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1100' AND '1392') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1100' AND '1392') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1100' AND '1392') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) =  '1053' OR (  Facts.Object ) = '1055' OR (  Facts.Object ) BETWEEN

    '1060' AND '1099') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) =  '1053' OR (  Facts.Object ) = '1055' OR (  Facts.Object ) BETWEEN

    '1060' AND '1099') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) =  '1053' OR (  Facts.Object ) = '1055' OR (  Facts.Object ) BETWEEN

    '1060' AND '1099') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) =  '1053' OR (  Facts.Object ) = '1055' OR (  Facts.Object ) BETWEEN

    '1060' AND '1099') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) =  '1053' OR (  Facts.Object ) = '1055' OR (  Facts.Object ) BETWEEN

    '1060' AND '1099') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) =  '1053' OR (  Facts.Object ) = '1055' OR (  Facts.Object ) BETWEEN

    '1060' AND '1099') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) =  '1053' OR (  Facts.Object ) = '1055' OR (  Facts.Object ) BETWEEN

    '1060' AND '1099') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) =  '1053' OR (  Facts.Object ) = '1055' OR (  Facts.Object ) BETWEEN

    '1060' AND '1099') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) =  '1053' OR (  Facts.Object ) = '1055' OR (  Facts.Object ) BETWEEN

    '1060' AND '1099') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) =  '1053' OR (  Facts.Object ) = '1055' OR (  Facts.Object ) BETWEEN

    '1060' AND '1099') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) =  '1053' OR (  Facts.Object ) = '1055' OR (  Facts.Object ) BETWEEN

    '1060' AND '1099') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) =  '1053' OR (  Facts.Object ) = '1055' OR (  Facts.Object ) BETWEEN

    '1060' AND '1099') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1400' AND '1449') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1400' AND '1449') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1400' AND '1449') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1400' AND '1449') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1400' AND '1449') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1400' AND '1449') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1400' AND '1449') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1400' AND '1449') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1400' AND '1449') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1400' AND '1449') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1400' AND '1449') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1400' AND '1449') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1500' AND '1521') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1500' AND '1521') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1500' AND '1521') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1500' AND '1521') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1500' AND '1521') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1500' AND '1521') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1500' AND '1521') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1500' AND '1521') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1500' AND '1521') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1500' AND '1521') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1500' AND '1521') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1500' AND '1521') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1570' AND '1579') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1570' AND '1579') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1570' AND '1579') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1570' AND '1579') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1570' AND '1579') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1570' AND '1579') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1570' AND '1579') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1570' AND '1579') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1570' AND '1579') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1570' AND '1579') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1570' AND '1579') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1570' AND '1579') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1550' AND '1569' OR (  Facts.Object ) BETWEEN  '1580' AND

    '1582') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1550' AND '1569' OR (  Facts.Object ) BETWEEN  '1580' AND

    '1582') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1550' AND '1569' OR (  Facts.Object ) BETWEEN  '1580' AND

    '1582') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1550' AND '1569' OR (  Facts.Object ) BETWEEN  '1580' AND

    '1582') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1550' AND '1569' OR (  Facts.Object ) BETWEEN  '1580' AND

    '1582') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1550' AND '1569' OR (  Facts.Object ) BETWEEN  '1580' AND

    '1582') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1550' AND '1569' OR (  Facts.Object ) BETWEEN  '1580' AND

    '1582') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1550' AND '1569' OR (  Facts.Object ) BETWEEN  '1580' AND

    '1582') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1550' AND '1569' OR (  Facts.Object ) BETWEEN  '1580' AND

    '1582') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1550' AND '1569' OR (  Facts.Object ) BETWEEN  '1580' AND

    '1582') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1550' AND '1569' OR (  Facts.Object ) BETWEEN  '1580' AND

    '1582') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1550' AND '1569' OR (  Facts.Object ) BETWEEN  '1580' AND

    '1582') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1600' AND '1602') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1600' AND '1602') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1600' AND '1602') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1600' AND '1602') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1600' AND '1602') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1600' AND '1602') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1600' AND '1602') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1600' AND '1602') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1600' AND '1602') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1600' AND '1602') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1600' AND '1602') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1600' AND '1602') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1610' AND '1613') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1610' AND '1613') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1610' AND '1613') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1610' AND '1613') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1610' AND '1613') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1610' AND '1613') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1610' AND '1613') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1610' AND '1613') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1610' AND '1613') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1610' AND '1613') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1610' AND '1613') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1610' AND '1613') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1620' AND '1621') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1620' AND '1621') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1620' AND '1621') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1620' AND '1621') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1620' AND '1621') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1620' AND '1621') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1620' AND '1621') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1620' AND '1621') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1620' AND '1621') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1620' AND '1621') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1620' AND '1621') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1620' AND '1621') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1630' AND '1634') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1630' AND '1634') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1630' AND '1634') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1630' AND '1634') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1630' AND '1634') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1630' AND '1634') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1630' AND '1634') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1630' AND '1634') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1630' AND '1634') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1630' AND '1634') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1630' AND '1634') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1630' AND '1634') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) =  '1640') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) =  '1640') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) =  '1640') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) =  '1640') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) =  '1640') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) =  '1640') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) =  '1640') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) =  '1640') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) =  '1640') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) =  '1640') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) =  '1640') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) =  '1640') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1650' AND '1652') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1650' AND '1652') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1650' AND '1652') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1650' AND '1652') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1650' AND '1652') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1650' AND '1652') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1650' AND '1652') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1650' AND '1652') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1650' AND '1652') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1650' AND '1652') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1650' AND '1652') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1650' AND '1652') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1700' AND '1740') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1700' AND '1740') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1700' AND '1740') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1700' AND '1740') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1700' AND '1740') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1700' AND '1740') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1700' AND '1740') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1700' AND '1740') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1700' AND '1740') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1700' AND '1740') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1700' AND '1740') then 

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1700' AND '1740') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1900' AND '1902') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1900' AND '1902') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1900' AND '1902') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1900' AND '1902') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1900' AND '1902') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1900' AND '1902') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1900' AND '1902') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1900' AND '1902') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1900' AND '1902') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1900' AND '1902') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1900' AND '1902') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1900' AND '1902') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1911' AND '1912') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1911' AND '1912') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1911' AND '1912') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1911' AND '1912') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1911' AND '1912') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1911' AND '1912') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1911' AND '1912') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1911' AND '1912') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1911' AND '1912') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1911' AND '1912') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1911' AND '1912') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1911' AND '1912') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1913' AND '1916') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1913' AND '1916') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1913' AND '1916') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1913' AND '1916') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1913' AND '1916') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1913' AND '1916') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1913' AND '1916') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1913' AND '1916') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1913' AND '1916') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1913' AND '1916') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1913' AND '1916') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1913' AND '1916') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1920' AND '1923') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1920' AND '1923') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1920' AND '1923') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1920' AND '1923') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1920' AND '1923') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1920' AND '1923') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1920' AND '1923') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1920' AND '1923') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1920' AND '1923') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1920' AND '1923') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1920' AND '1923') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1920' AND '1923') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1930' AND '1936') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1930' AND '1936') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1930' AND '1936') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1930' AND '1936') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1930' AND '1936') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1930' AND '1936') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1930' AND '1936') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1930' AND '1936') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1930' AND '1936') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1930' AND '1936') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1930' AND '1936') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1930' AND '1936') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1940' AND '1942') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1940' AND '1942') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1940' AND '1942') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1940' AND '1942') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1940' AND '1942') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1940' AND '1942') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1940' AND '1942') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1940' AND '1942') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1940' AND '1942') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1940' AND '1942') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1940' AND '1942') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1940' AND '1942') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1950' AND '1998') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1950' AND '1998') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1950' AND '1998') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1950' AND '1998') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1950' AND '1998') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1950' AND '1998') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1950' AND '1998') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1950' AND '1998') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1950' AND '1998') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1950' AND '1998') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1950' AND '1998') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1950' AND '1998') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '2000' AND '2013') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '2000' AND '2013') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '2000' AND '2013') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '2000' AND '2013') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '2000' AND '2013') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '2000' AND '2013') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '2000' AND '2013') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '2000' AND '2013') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '2000' AND '2013') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '2000' AND '2013') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '2000' AND '2013') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '2000' AND '2013') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '2050' AND '2070') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '2050' AND '2070') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '2050' AND '2070') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '2050' AND '2070') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '2050' AND '2070') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '2050' AND '2070') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '2050' AND '2070') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '2050' AND '2070') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '2050' AND '2070') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '2050' AND '2070') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '2050' AND '2070') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '2050' AND '2070') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '2100' AND '2149') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '2100' AND '2149') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '2100' AND '2149') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '2100' AND '2149') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '2100' AND '2149') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '2100' AND '2149') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '2100' AND '2149') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '2100' AND '2149') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '2100' AND '2149') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '2100' AND '2149') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '2100' AND '2149') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '2100' AND '2149') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '2200' AND '2241' OR (  Facts.Object ) BETWEEN  '2243' AND

    '2299') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '2200' AND '2241' OR (  Facts.Object ) BETWEEN  '2243' AND

    '2299') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '2200' AND '2241' OR (  Facts.Object ) BETWEEN  '2243' AND

    '2299') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '2200' AND '2241' OR (  Facts.Object ) BETWEEN  '2243' AND

    '2299') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '2200' AND '2241' OR (  Facts.Object ) BETWEEN  '2243' AND

    '2299') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '2200' AND '2241' OR (  Facts.Object ) BETWEEN  '2243' AND

    '2299') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '2200' AND '2241' OR (  Facts.Object ) BETWEEN  '2243' AND

    '2299') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '2200' AND '2241' OR (  Facts.Object ) BETWEEN  '2243' AND

    '2299') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '2200' AND '2241' OR (  Facts.Object ) BETWEEN  '2243' AND

    '2299') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '2200' AND '2241' OR (  Facts.Object ) BETWEEN  '2243' AND

    '2299') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '2200' AND '2241' OR (  Facts.Object ) BETWEEN  '2243' AND

    '2299') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '2200' AND '2241' OR (  Facts.Object ) BETWEEN  '2243' AND

    '2299') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) =  '2242') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) =  '2242') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) =  '2242') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) =  '2242') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) =  '2242') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) =  '2242') then 

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) =  '2242') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) =  '2242') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) =  '2242') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) =  '2242') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) =  '2242') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) =  '2242') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '2300' AND '2340') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '2300' AND '2340') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '2300' AND '2340') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '2300' AND '2340') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '2300' AND '2340') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '2300' AND '2340') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '2300' AND '2340') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '2300' AND '2340') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '2300' AND '2340') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '2300' AND '2340') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '2300' AND '2340') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '2300' AND '2340') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '2400' AND '2421') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '2400' AND '2421') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '2400' AND '2421') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '2400' AND '2421') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '2400' AND '2421') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '2400' AND '2421') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '2400' AND '2421') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '2400' AND '2421') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '2400' AND '2421') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '2400' AND '2421') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '2400' AND '2421') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '2400' AND '2421') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '2500' AND '2515') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '2500' AND '2515') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '2500' AND '2515') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '2500' AND '2515') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '2500' AND '2515') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '2500' AND '2515') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '2500' AND '2515') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '2500' AND '2515') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '2500' AND '2515') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '2500' AND '2515') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '2500' AND '2515') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '2500' AND '2515') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '2700' AND '2710') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '2700' AND '2710') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '2700' AND '2710') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '2700' AND '2710') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '2700' AND '2710') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '2700' AND '2710') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '2700' AND '2710') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '2700' AND '2710') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '2700' AND '2710') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '2700' AND '2710') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '2700' AND '2710') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '2700' AND '2710') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '2720' AND '2723') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '2720' AND '2723') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '2720' AND '2723') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '2720' AND '2723') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '2720' AND '2723') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '2720' AND '2723') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '2720' AND '2723') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '2720' AND '2723') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '2720' AND '2723') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '2720' AND '2723') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '2720' AND '2723') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '2720' AND '2723') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '2730' AND '2749') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '2730' AND '2749') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '2730' AND '2749') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '2730' AND '2749') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '2730' AND '2749') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '2730' AND '2749') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '2730' AND '2749') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '2730' AND '2749') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '2730' AND '2749') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '2730' AND '2749') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '2730' AND '2749') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '2730' AND '2749') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) =  '2800') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) =  '2800') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) =  '2800') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) =  '2800') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) =  '2800') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) =  '2800') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) =  '2800') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) =  '2800') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) =  '2800') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) =  '2800') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) =  '2800') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) =  '2800') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '2750' AND '2755') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '2750' AND '2755') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '2750' AND '2755') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '2750' AND '2755') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '2750' AND '2755') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '2750' AND '2755') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '2750' AND '2755') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '2750' AND '2755') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '2750' AND '2755') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '2750' AND '2755') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '2750' AND '2755') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '2750' AND '2755') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '3000' AND '3001') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '3000' AND '3001') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '3000' AND '3001') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '3000' AND '3001') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '3000' AND '3001') then 

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '3000' AND '3001') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '3000' AND '3001') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '3000' AND '3001') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '3000' AND '3001') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '3000' AND '3001') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '3000' AND '3001') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '3000' AND '3001') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '3050' AND '3070') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '3050' AND '3070') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '3050' AND '3070') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '3050' AND '3070') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '3050' AND '3070') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '3050' AND '3070') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '3050' AND '3070') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '3050' AND '3070') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '3050' AND '3070') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '3050' AND '3070') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '3050' AND '3070') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '3050' AND '3070') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) =  '3211') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) =  '3211') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) =  '3211') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) =  '3211') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) =  '3211') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) =  '3211') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) =  '3211') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) =  '3211') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) =  '3211') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) =  '3211') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) =  '3211') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) =  '3211') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '3100' AND '3101') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '3100' AND '3101') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '3100' AND '3101') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '3100' AND '3101') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '3100' AND '3101') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '3100' AND '3101') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '3100' AND '3101') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '3100' AND '3101') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '3100' AND '3101') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '3100' AND '3101') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '3100' AND '3101') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '3100' AND '3101') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '3150' AND '3151') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '3150' AND '3151') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '3150' AND '3151') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '3150' AND '3151') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '3150' AND '3151') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '3150' AND '3151') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '3150' AND '3151') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '3150' AND '3151') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '3150' AND '3151') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '3150' AND '3151') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '3150' AND '3151') then 

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '3150' AND '3151') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '3200' AND '3201') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '3200' AND '3201') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '3200' AND '3201') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '3200' AND '3201') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '3200' AND '3201') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '3200' AND '3201') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '3200' AND '3201') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '3200' AND '3201') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '3200' AND '3201') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '3200' AND '3201') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '3200' AND '3201') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '3200' AND '3201') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '3900' AND '3999') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '3900' AND '3999') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '3900' AND '3999') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '3900' AND '3999') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '3900' AND '3999') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '3900' AND '3999') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '3900' AND '3999') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '3900' AND '3999') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '3900' AND '3999') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '3900' AND '3999') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '3900' AND '3999') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '3900' AND '3999') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '4000' AND '7999') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '4000' AND '7999') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '4000' AND '7999') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '4000' AND '7999') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '4000' AND '7999') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '4000' AND '7999') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '4000' AND '7999') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '4000' AND '7999') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '4000' AND '7999') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '4000' AND '7999') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '4000' AND '7999') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '4000' AND '7999') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '1000' AND '1999') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '1000' AND '1999') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '1000' AND '1999') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '1000' AND '1999') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '1000' AND '1999') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '1000' AND '1999') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '1000' AND '1999') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '1000' AND '1999') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '1000' AND '1999') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '1000' AND '1999') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '1000' AND '1999') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '1000' AND '1999') then

    ( Facts.Balance12)

    else 0

    END),

      sum(CASE

    when    FiscalYear.FiscalYear= 2006 and 5 = '01' and ((  Facts.Object ) BETWEEN  '2000' AND '8999') then

    ( Facts.Balance01)

    when    FiscalYear.FiscalYear= 2006 and 5 = '02' and ((  Facts.Object ) BETWEEN  '2000' AND '8999') then

    ( Facts.Balance02)

    when    FiscalYear.FiscalYear= 2006 and 5 = '03' and ((  Facts.Object ) BETWEEN  '2000' AND '8999') then

    ( Facts.Balance03)

    when    FiscalYear.FiscalYear= 2006 and 5 = '04' and ((  Facts.Object ) BETWEEN  '2000' AND '8999') then

    ( Facts.Balance04)

    when    FiscalYear.FiscalYear= 2006 and 5 = '05' and ((  Facts.Object ) BETWEEN  '2000' AND '8999') then

    ( Facts.Balance05)

    when    FiscalYear.FiscalYear= 2006 and 5 = '06' and ((  Facts.Object ) BETWEEN  '2000' AND '8999') then

    ( Facts.Balance06)

    when    FiscalYear.FiscalYear= 2006 and 5 = '07' and ((  Facts.Object ) BETWEEN  '2000' AND '8999') then

    ( Facts.Balance07)

    when    FiscalYear.FiscalYear= 2006 and 5 = '08' and ((  Facts.Object ) BETWEEN  '2000' AND '8999') then

    ( Facts.Balance08)

    when    FiscalYear.FiscalYear= 2006 and 5 = '09' and ((  Facts.Object ) BETWEEN  '2000' AND '8999') then

    ( Facts.Balance09)

    when    FiscalYear.FiscalYear= 2006 and 5 = '10' and ((  Facts.Object ) BETWEEN  '2000' AND '8999') then

    ( Facts.Balance10)

    when    FiscalYear.FiscalYear= 2006 and 5 = '11' and ((  Facts.Object ) BETWEEN  '2000' AND '8999') then

    ( Facts.Balance11)

    when    FiscalYear.FiscalYear= 2006 and 5 = '12' and ((  Facts.Object ) BETWEEN  '2000' AND '8999') then

    ( Facts.Balance12)

    else 0

    END)

    FROM

      dbo.GL_Star_Facts2006  Facts,

      dbo.GL_Star_Account  Account, -- This is a view on Star_account table above

      dbo.GL_Star_BusinessUnit  Business_Unit, -- This is a view on Star_BusinessUnit table above.

      dbo.GL_Star_FiscalYear  FiscalYear,

      dbo.GL_Star_Ledger  Ledger

    WHERE

      ( Facts.FiscalYear=FiscalYear.FiscalYear and Facts.SourceID=FiscalYear.SourceID  )

      AND  ( Facts.Account=Account.Account and Facts.SourceID=Account.SourceID  )

      AND  ( Facts.BusinessUnitCode=Business_Unit.BusinessUnitCode and Facts.SourceID=Business_Unit.SourceID  )

      AND  ( Facts.LedgerTypeCode=Ledger.LedgerTypeCode and Facts.SourceID=Ledger.SourceID   )

      AND  ( FiscalYear.FiscalDatePattern= 'R'  )

      AND 

      (

       Ledger.LedgerTypeCode  In  ( 'AC'  )

       AND

       Account.Object  BETWEEN  '1000'  AND  '8999'

       AND

       FiscalYear.FiscalYear  =  2006

      )

    GROUP BY

      Business_Unit.Category15Code,

      Business_Unit.Category15,

      Business_Unit.Category20,

      Business_Unit.Category21Code,

        CASE

      when ( Business_Unit.Category15Code ) In  ( 'NA','KI','EH','KO','UM','H') then 'NAR'

      when ( Business_Unit.Category20Code ) In  ( 'I','E') then 'ER'

      when ( Business_Unit.Category20Code ) In  ( 'A') then 'AL'

      when ( Business_Unit.Category15Code ) In  ( 'U') then 'UUU'

      when ( Business_Unit.Category15Code ) In  ( 'T') then 'TTT'

      when ( Business_Unit.Category15Code ) In  ( 'HE') then 'HEQ'

      when ( Business_Unit.Category15Code ) In  ( 'E') then 'ELL'

      else 'Other'

      end,

        CASE

      when ( Business_Unit.Category15Code ) In  ( 'NA','KI','EH','KO','UM','H') then 'NAR'

      when ( Business_Unit.Category20Code ) In  ( 'I','E')  then 'ER'

      when ( Business_Unit.Category20Code ) In  ( 'A') then 'AL'

      else 'Other'

      end,

        CASE

      when ( Business_Unit.Category15Code ) In  ( 'U') then 'UUU'

      when ( Business_Unit.Category15Code ) In  ( 'T') then 'TTT'

      when ( Business_Unit.Category15Code ) In  ( 'HE') then 'HEQ'

      when ( Business_Unit.Category15Code ) In  ( 'E') then 'ELL'

      else 'Other'

    end

    =================================================================================

    Note: GL_Star_Facts2006 has 7.6 million rows and Star_Account table has 7.9 million rows. Other tables have substantially very less (25000) rows.

    We are using BusinessObjects' Universes for reporting purposes and this query was generated by BusinessObjects.

  • RSingh,

    probably your company needs to hire a professional to build your database and your queries.

    Almost everything I see here is just inappropriate.

    Everything.

    This toy may work for dull databases with no more than 5k records.

    But not any bigger.

    For real database you need real thing.

    There is nothing to fix.

    It must be redone from scratch to make it work.

    Sorry.

    _____________
    Code for TallyGenerator

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply