Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Rollup, Cube woes!! Expand / Collapse
Author
Message
Posted Thursday, March 13, 2014 3:12 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, December 15, 2014 4:30 AM
Points: 121, Visits: 429
Hi

i have a fairly large data set which i want to add totals to. Usually i would go down the road of creating aggregated views and then create a union query to join them.

However, i've since found with rollup and cube. :)

The problem i have is i'd like to have different levels of aggregation. i.e a total at product category level and another at account level.

here's the table
CREATE TABLE [dbo].[tempTable](
[Sort] [int] NOT NULL,
[AggregateLevel] [varchar](35) NOT NULL,
[TimeKey] [int] NOT NULL,
[Year] [int] NULL,
[MonthNumber] [int] NULL,
[AccountCodePK] [varchar](7) NULL,
[AccountName] [varchar](100) NULL,
[PharmToilet] [varchar](1) NULL,
[StockCodePK] [varchar](35) NULL,
[StockDescription] [varchar](100) NULL,
[RangeId] [varchar](100) NULL,
[RangeDescr] [varchar](100) NULL,
[SubRangeId] [int] NULL,
[SubRangeDescr] [varchar](100) NULL,
[ValueSalesCMTD] [numeric](38, 2) NULL,
[ValueSalesCYTD] [numeric](38, 2) NULL,
[ValueSalesPMTD] [numeric](38, 2) NULL,
[ValueSalesPYTD] [numeric](38, 2) NULL
)

and here's some records......

delete from dbo.tempTable
insert into dbo.tempTable


select 0 as Sort, 'Product' as AggregateLevel, 73 as TimeKey, 2014 as Year, 1 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925620' as StockCodePK, 'Strawberry Puree' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 74 as TimeKey, 2014 as Year, 2 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925620' as StockCodePK, 'Strawberry Puree' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 75 as TimeKey, 2014 as Year, 3 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925620' as StockCodePK, 'Strawberry Puree' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 76 as TimeKey, 2014 as Year, 4 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925620' as StockCodePK, 'Strawberry Puree' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 77 as TimeKey, 2014 as Year, 5 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925620' as StockCodePK, 'Strawberry Puree' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 78 as TimeKey, 2014 as Year, 6 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925620' as StockCodePK, 'Strawberry Puree' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 79 as TimeKey, 2014 as Year, 7 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925620' as StockCodePK, 'Strawberry Puree' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 80 as TimeKey, 2014 as Year, 8 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925620' as StockCodePK, 'Strawberry Puree' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 81 as TimeKey, 2014 as Year, 9 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925620' as StockCodePK, 'Strawberry Puree' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 82 as TimeKey, 2014 as Year, 10 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925620' as StockCodePK, 'Strawberry Puree' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 83 as TimeKey, 2014 as Year, 11 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925620' as StockCodePK, 'Strawberry Puree' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 84 as TimeKey, 2014 as Year, 12 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925620' as StockCodePK, 'Strawberry Puree' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 73 as TimeKey, 2014 as Year, 1 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925953' as StockCodePK, 'Camomile EMUR 60ml AO' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 74 as TimeKey, 2014 as Year, 2 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925953' as StockCodePK, 'Camomile EMUR 60ml AO' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 75 as TimeKey, 2014 as Year, 3 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925953' as StockCodePK, 'Camomile EMUR 60ml AO' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 76 as TimeKey, 2014 as Year, 4 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925953' as StockCodePK, 'Camomile EMUR 60ml AO' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 77 as TimeKey, 2014 as Year, 5 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925953' as StockCodePK, 'Camomile EMUR 60ml AO' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 78 as TimeKey, 2014 as Year, 6 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925953' as StockCodePK, 'Camomile EMUR 60ml AO' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 79 as TimeKey, 2014 as Year, 7 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925953' as StockCodePK, 'Camomile EMUR 60ml AO' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 80 as TimeKey, 2014 as Year, 8 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925953' as StockCodePK, 'Camomile EMUR 60ml AO' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 81 as TimeKey, 2014 as Year, 9 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925953' as StockCodePK, 'Camomile EMUR 60ml AO' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 82 as TimeKey, 2014 as Year, 10 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925953' as StockCodePK, 'Camomile EMUR 60ml AO' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 83 as TimeKey, 2014 as Year, 11 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925953' as StockCodePK, 'Camomile EMUR 60ml AO' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 84 as TimeKey, 2014 as Year, 12 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '925953' as StockCodePK, 'Camomile EMUR 60ml AO' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 73 as TimeKey, 2014 as Year, 1 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926170' as StockCodePK, 'Ice Blue Shampoo' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 74 as TimeKey, 2014 as Year, 2 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926170' as StockCodePK, 'Ice Blue Shampoo' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 75 as TimeKey, 2014 as Year, 3 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926170' as StockCodePK, 'Ice Blue Shampoo' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 76 as TimeKey, 2014 as Year, 4 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926170' as StockCodePK, 'Ice Blue Shampoo' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 77 as TimeKey, 2014 as Year, 5 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926170' as StockCodePK, 'Ice Blue Shampoo' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 78 as TimeKey, 2014 as Year, 6 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926170' as StockCodePK, 'Ice Blue Shampoo' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 79 as TimeKey, 2014 as Year, 7 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926170' as StockCodePK, 'Ice Blue Shampoo' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 80 as TimeKey, 2014 as Year, 8 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926170' as StockCodePK, 'Ice Blue Shampoo' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 81 as TimeKey, 2014 as Year, 9 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926170' as StockCodePK, 'Ice Blue Shampoo' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 82 as TimeKey, 2014 as Year, 10 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926170' as StockCodePK, 'Ice Blue Shampoo' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 83 as TimeKey, 2014 as Year, 11 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926170' as StockCodePK, 'Ice Blue Shampoo' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 84 as TimeKey, 2014 as Year, 12 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926170' as StockCodePK, 'Ice Blue Shampoo' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 73 as TimeKey, 2014 as Year, 1 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926181' as StockCodePK, 'Cucumber Milk' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 74 as TimeKey, 2014 as Year, 2 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926181' as StockCodePK, 'Cucumber Milk' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 75 as TimeKey, 2014 as Year, 3 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926181' as StockCodePK, 'Cucumber Milk' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 76 as TimeKey, 2014 as Year, 4 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926181' as StockCodePK, 'Cucumber Milk' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 77 as TimeKey, 2014 as Year, 5 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926181' as StockCodePK, 'Cucumber Milk' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 78 as TimeKey, 2014 as Year, 6 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926181' as StockCodePK, 'Cucumber Milk' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 79 as TimeKey, 2014 as Year, 7 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926181' as StockCodePK, 'Cucumber Milk' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 80 as TimeKey, 2014 as Year, 8 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926181' as StockCodePK, 'Cucumber Milk' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 81 as TimeKey, 2014 as Year, 9 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926181' as StockCodePK, 'Cucumber Milk' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 82 as TimeKey, 2014 as Year, 10 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926181' as StockCodePK, 'Cucumber Milk' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 83 as TimeKey, 2014 as Year, 11 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926181' as StockCodePK, 'Cucumber Milk' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 84 as TimeKey, 2014 as Year, 12 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926181' as StockCodePK, 'Cucumber Milk' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 73 as TimeKey, 2014 as Year, 1 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926183' as StockCodePK, 'Dewberry Body Lotion' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 74 as TimeKey, 2014 as Year, 2 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926183' as StockCodePK, 'Dewberry Body Lotion' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 75 as TimeKey, 2014 as Year, 3 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926183' as StockCodePK, 'Dewberry Body Lotion' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 76 as TimeKey, 2014 as Year, 4 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926183' as StockCodePK, 'Dewberry Body Lotion' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 77 as TimeKey, 2014 as Year, 5 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926183' as StockCodePK, 'Dewberry Body Lotion' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 78 as TimeKey, 2014 as Year, 6 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926183' as StockCodePK, 'Dewberry Body Lotion' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 79 as TimeKey, 2014 as Year, 7 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926183' as StockCodePK, 'Dewberry Body Lotion' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 80 as TimeKey, 2014 as Year, 8 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926183' as StockCodePK, 'Dewberry Body Lotion' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 81 as TimeKey, 2014 as Year, 9 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926183' as StockCodePK, 'Dewberry Body Lotion' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 82 as TimeKey, 2014 as Year, 10 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926183' as StockCodePK, 'Dewberry Body Lotion' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 83 as TimeKey, 2014 as Year, 11 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926183' as StockCodePK, 'Dewberry Body Lotion' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 84 as TimeKey, 2014 as Year, 12 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926183' as StockCodePK, 'Dewberry Body Lotion' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 73 as TimeKey, 2014 as Year, 1 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926263' as StockCodePK, 'Lemon Hand Wash ARX' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 74 as TimeKey, 2014 as Year, 2 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926263' as StockCodePK, 'Lemon Hand Wash ARX' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 75 as TimeKey, 2014 as Year, 3 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926263' as StockCodePK, 'Lemon Hand Wash ARX' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 76 as TimeKey, 2014 as Year, 4 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926263' as StockCodePK, 'Lemon Hand Wash ARX' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 77 as TimeKey, 2014 as Year, 5 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926263' as StockCodePK, 'Lemon Hand Wash ARX' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 78 as TimeKey, 2014 as Year, 6 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926263' as StockCodePK, 'Lemon Hand Wash ARX' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 79 as TimeKey, 2014 as Year, 7 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926263' as StockCodePK, 'Lemon Hand Wash ARX' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 80 as TimeKey, 2014 as Year, 8 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926263' as StockCodePK, 'Lemon Hand Wash ARX' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 81 as TimeKey, 2014 as Year, 9 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926263' as StockCodePK, 'Lemon Hand Wash ARX' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 82 as TimeKey, 2014 as Year, 10 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926263' as StockCodePK, 'Lemon Hand Wash ARX' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 83 as TimeKey, 2014 as Year, 11 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926263' as StockCodePK, 'Lemon Hand Wash ARX' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 84 as TimeKey, 2014 as Year, 12 as MonthNumber, 'B001' as AccountCodePK, 'A.NOTHER SHOP' as AccountName, 'T' as PharmToilet, '926263' as StockCodePK, 'Lemon Hand Wash ARX' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 73 as TimeKey, 2014 as Year, 1 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924044' as StockCodePK, 'Facial Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 2774.4 as ValueSalesPMTD, 2774.4 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 74 as TimeKey, 2014 as Year, 2 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924044' as StockCodePK, 'Facial Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 16575 as ValueSalesPMTD, 19349.4 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 75 as TimeKey, 2014 as Year, 3 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924044' as StockCodePK, 'Facial Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 1657.5 as ValueSalesPMTD, 21006.9 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 76 as TimeKey, 2014 as Year, 4 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924044' as StockCodePK, 'Facial Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 7624.5 as ValueSalesPMTD, 28631.4 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 77 as TimeKey, 2014 as Year, 5 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924044' as StockCodePK, 'Facial Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 7956 as ValueSalesPMTD, 36587.4 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 78 as TimeKey, 2014 as Year, 6 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924044' as StockCodePK, 'Facial Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 6961.5 as ValueSalesPMTD, 43548.9 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 79 as TimeKey, 2014 as Year, 7 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924044' as StockCodePK, 'Facial Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 16906.5 as ValueSalesPMTD, 60455.4 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 80 as TimeKey, 2014 as Year, 8 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924044' as StockCodePK, 'Facial Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 12928.5 as ValueSalesPMTD, 73383.9 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 81 as TimeKey, 2014 as Year, 9 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924044' as StockCodePK, 'Facial Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 3248.7 as ValueSalesPMTD, 76632.6 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 82 as TimeKey, 2014 as Year, 10 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924044' as StockCodePK, 'Facial Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 83 as TimeKey, 2014 as Year, 11 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924044' as StockCodePK, 'Facial Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 84 as TimeKey, 2014 as Year, 12 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924044' as StockCodePK, 'Facial Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 73 as TimeKey, 2014 as Year, 1 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924053' as StockCodePK, 'Foaming Face Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 11776.32 as ValueSalesPMTD, 11776.32 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 74 as TimeKey, 2014 as Year, 2 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924053' as StockCodePK, 'Foaming Face Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 4060.8 as ValueSalesPMTD, 15837.12 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 75 as TimeKey, 2014 as Year, 3 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924053' as StockCodePK, 'Foaming Face Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 5279.04 as ValueSalesPMTD, 21116.16 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 76 as TimeKey, 2014 as Year, 4 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924053' as StockCodePK, 'Foaming Face Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 8527.68 as ValueSalesPMTD, 29643.84 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 77 as TimeKey, 2014 as Year, 5 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924053' as StockCodePK, 'Foaming Face Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 8933.76 as ValueSalesPMTD, 38577.6 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 78 as TimeKey, 2014 as Year, 6 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924053' as StockCodePK, 'Foaming Face Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 7309.44 as ValueSalesPMTD, 45887.04 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 79 as TimeKey, 2014 as Year, 7 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924053' as StockCodePK, 'Foaming Face Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 9339.84 as ValueSalesPMTD, 55226.88 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 80 as TimeKey, 2014 as Year, 8 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924053' as StockCodePK, 'Foaming Face Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 10152 as ValueSalesPMTD, 65378.88 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 81 as TimeKey, 2014 as Year, 9 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924053' as StockCodePK, 'Foaming Face Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 0 as ValueSalesPMTD, 65378.88 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 82 as TimeKey, 2014 as Year, 10 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924053' as StockCodePK, 'Foaming Face Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 6091.2 as ValueSalesPMTD, 71470.08 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 83 as TimeKey, 2014 as Year, 11 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924053' as StockCodePK, 'Foaming Face Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 12588.48 as ValueSalesPMTD, 84058.56 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 84 as TimeKey, 2014 as Year, 12 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924053' as StockCodePK, 'Foaming Face Wash' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 3914.16 as ValueSalesPMTD, 87972.72 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 73 as TimeKey, 2014 as Year, 1 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924075' as StockCodePK, 'Essential Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 8265.6 as ValueSalesPMTD, 8265.6 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 74 as TimeKey, 2014 as Year, 2 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924075' as StockCodePK, 'Essential Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 3542.4 as ValueSalesPMTD, 11808 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 75 as TimeKey, 2014 as Year, 3 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924075' as StockCodePK, 'Essential Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 3542.4 as ValueSalesPMTD, 15350.4 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 76 as TimeKey, 2014 as Year, 4 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924075' as StockCodePK, 'Essential Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 7084.8 as ValueSalesPMTD, 22435.2 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 77 as TimeKey, 2014 as Year, 5 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924075' as StockCodePK, 'Essential Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 5904 as ValueSalesPMTD, 28339.2 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 78 as TimeKey, 2014 as Year, 6 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924075' as StockCodePK, 'Essential Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 8265.6 as ValueSalesPMTD, 36604.8 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 79 as TimeKey, 2014 as Year, 7 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924075' as StockCodePK, 'Essential Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 4723.2 as ValueSalesPMTD, 41328 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 80 as TimeKey, 2014 as Year, 8 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924075' as StockCodePK, 'Essential Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 3296.4 as ValueSalesPMTD, 44624.4 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 81 as TimeKey, 2014 as Year, 9 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924075' as StockCodePK, 'Essential Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 12988.8 as ValueSalesPMTD, 57613.2 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 82 as TimeKey, 2014 as Year, 10 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924075' as StockCodePK, 'Essential Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 5067.6 as ValueSalesPMTD, 62680.8 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 83 as TimeKey, 2014 as Year, 11 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924075' as StockCodePK, 'Essential Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 84 as TimeKey, 2014 as Year, 12 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924075' as StockCodePK, 'Essential Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 73 as TimeKey, 2014 as Year, 1 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924076' as StockCodePK, 'Blended Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 3504 as ValueSalesPMTD, 3504 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 74 as TimeKey, 2014 as Year, 2 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924076' as StockCodePK, 'Blended Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 2365.2 as ValueSalesPMTD, 5869.2 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 75 as TimeKey, 2014 as Year, 3 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924076' as StockCodePK, 'Blended Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 1576.8 as ValueSalesPMTD, 7446 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 76 as TimeKey, 2014 as Year, 4 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924076' as StockCodePK, 'Blended Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 2365.2 as ValueSalesPMTD, 9811.2 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 77 as TimeKey, 2014 as Year, 5 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924076' as StockCodePK, 'Blended Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 3942 as ValueSalesPMTD, 13753.2 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 78 as TimeKey, 2014 as Year, 6 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924076' as StockCodePK, 'Blended Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 4336.2 as ValueSalesPMTD, 18089.4 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 79 as TimeKey, 2014 as Year, 7 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924076' as StockCodePK, 'Blended Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 2711.22 as ValueSalesPMTD, 20800.62 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 80 as TimeKey, 2014 as Year, 8 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924076' as StockCodePK, 'Blended Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 3942 as ValueSalesPMTD, 24742.62 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 81 as TimeKey, 2014 as Year, 9 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924076' as StockCodePK, 'Blended Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 6307.2 as ValueSalesPMTD, 31049.82 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 82 as TimeKey, 2014 as Year, 10 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924076' as StockCodePK, 'Blended Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, -87.6 as ValueSalesPMTD, 30962.22 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 83 as TimeKey, 2014 as Year, 11 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924076' as StockCodePK, 'Blended Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 84 as TimeKey, 2014 as Year, 12 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924076' as StockCodePK, 'Blended Oil' as StockDescription, NULL as RangeId, 'NULL' as RangeDescr, NULL as SubRangeId, 'NULL' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 73 as TimeKey, 2014 as Year, 1 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924907' as StockCodePK, 'Mud Mask Sachets' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 437 as SubRangeId, 'Naturals Body Care' as SubRangeDescr, 1034.28 as ValueSalesCMTD, 1034.28 as ValueSalesCYTD, 2068.56 as ValueSalesPMTD, 2068.56 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 74 as TimeKey, 2014 as Year, 2 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924907' as StockCodePK, 'Mud Mask Sachets' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 437 as SubRangeId, 'Naturals Body Care' as SubRangeDescr, 1034.28 as ValueSalesCMTD, 2068.56 as ValueSalesCYTD, 1034.28 as ValueSalesPMTD, 3102.84 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 75 as TimeKey, 2014 as Year, 3 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924907' as StockCodePK, 'Mud Mask Sachets' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 437 as SubRangeId, 'Naturals Body Care' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 2068.56 as ValueSalesPMTD, 5171.4 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 76 as TimeKey, 2014 as Year, 4 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924907' as StockCodePK, 'Mud Mask Sachets' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 437 as SubRangeId, 'Naturals Body Care' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 1034.28 as ValueSalesPMTD, 6205.68 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 77 as TimeKey, 2014 as Year, 5 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924907' as StockCodePK, 'Mud Mask Sachets' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 437 as SubRangeId, 'Naturals Body Care' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 2068.56 as ValueSalesPMTD, 8274.24 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 78 as TimeKey, 2014 as Year, 6 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924907' as StockCodePK, 'Mud Mask Sachets' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 437 as SubRangeId, 'Naturals Body Care' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 1034.28 as ValueSalesPMTD, 9308.52 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 79 as TimeKey, 2014 as Year, 7 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924907' as StockCodePK, 'Mud Mask Sachets' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 437 as SubRangeId, 'Naturals Body Care' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 1034.28 as ValueSalesPMTD, 10342.8 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 80 as TimeKey, 2014 as Year, 8 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924907' as StockCodePK, 'Mud Mask Sachets' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 437 as SubRangeId, 'Naturals Body Care' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 2068.56 as ValueSalesPMTD, 12411.36 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 81 as TimeKey, 2014 as Year, 9 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924907' as StockCodePK, 'Mud Mask Sachets' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 437 as SubRangeId, 'Naturals Body Care' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 1034.28 as ValueSalesPMTD, 13445.64 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 82 as TimeKey, 2014 as Year, 10 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924907' as StockCodePK, 'Mud Mask Sachets' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 437 as SubRangeId, 'Naturals Body Care' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 2616.12 as ValueSalesPMTD, 16061.76 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 83 as TimeKey, 2014 as Year, 11 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924907' as StockCodePK, 'Mud Mask Sachets' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 437 as SubRangeId, 'Naturals Body Care' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 2068.56 as ValueSalesPMTD, 18130.32 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 84 as TimeKey, 2014 as Year, 12 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '924907' as StockCodePK, 'Mud Mask Sachets' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 437 as SubRangeId, 'Naturals Body Care' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 1034.28 as ValueSalesPMTD, 19164.6 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 73 as TimeKey, 2014 as Year, 1 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925221' as StockCodePK, 'Aloe Vera' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 74 as TimeKey, 2014 as Year, 2 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925221' as StockCodePK, 'Aloe Vera' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 3484.8 as ValueSalesPMTD, 3484.8 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 75 as TimeKey, 2014 as Year, 3 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925221' as StockCodePK, 'Aloe Vera' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 3484.8 as ValueSalesPMTD, 6969.6 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 76 as TimeKey, 2014 as Year, 4 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925221' as StockCodePK, 'Aloe Vera' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 950.4 as ValueSalesPMTD, 7920 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 77 as TimeKey, 2014 as Year, 5 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925221' as StockCodePK, 'Aloe Vera' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 1900.8 as ValueSalesPMTD, 9820.8 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 78 as TimeKey, 2014 as Year, 6 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925221' as StockCodePK, 'Aloe Vera' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 1900.8 as ValueSalesPMTD, 11721.6 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 79 as TimeKey, 2014 as Year, 7 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925221' as StockCodePK, 'Aloe Vera' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 2217.6 as ValueSalesPMTD, 13939.2 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 80 as TimeKey, 2014 as Year, 8 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925221' as StockCodePK, 'Aloe Vera' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 2534.4 as ValueSalesPMTD, 16473.6 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 81 as TimeKey, 2014 as Year, 9 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925221' as StockCodePK, 'Aloe Vera' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 498.3 as ValueSalesPMTD, 16971.9 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 82 as TimeKey, 2014 as Year, 10 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925221' as StockCodePK, 'Aloe Vera' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 83 as TimeKey, 2014 as Year, 11 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925221' as StockCodePK, 'Aloe Vera' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 84 as TimeKey, 2014 as Year, 12 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925221' as StockCodePK, 'Aloe Vera' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 73 as TimeKey, 2014 as Year, 1 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925222' as StockCodePK, 'Raspberry' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 336.3 as ValueSalesPMTD, 336.3 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 74 as TimeKey, 2014 as Year, 2 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925222' as StockCodePK, 'Raspberry' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 75 as TimeKey, 2014 as Year, 3 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925222' as StockCodePK, 'Raspberry' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 6456.96 as ValueSalesPMTD, 6793.26 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 76 as TimeKey, 2014 as Year, 4 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925222' as StockCodePK, 'Raspberry' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 77 as TimeKey, 2014 as Year, 5 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925222' as StockCodePK, 'Raspberry' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 78 as TimeKey, 2014 as Year, 6 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925222' as StockCodePK, 'Raspberry' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 339.84 as ValueSalesPMTD, 7133.1 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 79 as TimeKey, 2014 as Year, 7 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925222' as StockCodePK, 'Raspberry' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 1019.52 as ValueSalesPMTD, 8152.62 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 80 as TimeKey, 2014 as Year, 8 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925222' as StockCodePK, 'Raspberry' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 1019.52 as ValueSalesPMTD, 9172.14 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 81 as TimeKey, 2014 as Year, 9 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925222' as StockCodePK, 'Raspberry' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, 1044.3 as ValueSalesPMTD, 10216.44 as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 82 as TimeKey, 2014 as Year, 10 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925222' as StockCodePK, 'Raspberry' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 83 as TimeKey, 2014 as Year, 11 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925222' as StockCodePK, 'Raspberry' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD union
select 0 as Sort, 'Product' as AggregateLevel, 84 as TimeKey, 2014 as Year, 12 as MonthNumber, 'S002' as AccountCodePK, 'A DRUG STORE' as AccountName, 'T' as PharmToilet, '925222' as StockCodePK, 'Raspberry' as StockDescription, 1 as RangeId, 'UNCATEGORISED' as RangeDescr, 404 as SubRangeId, 'Camomile' as SubRangeDescr, NULL as ValueSalesCMTD, NULL as ValueSalesCYTD, NULL as ValueSalesPMTD, NULL as ValueSalesPYTD

...is it possible with the above data set in sql2005 to group by certain fields without having to declare every field in the group by clause? or do i need to stick with the union method?

Thanks
Post #1550581
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse