Grouping & Group by

  • I am attempting to group a column which represents dates as YYYYMMDDHH as an integer. I want to sum a sales column and then provide the total using the grouping keyword. Here is my query for your convenience I have given you the script to create the table.

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[MySourceTable]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

    drop table [dbo].[MySourceTable]

    GO

    CREATE TABLE [dbo].[MySourceTable] (

    [YMDH] [int] NOT NULL ,

    [Sales] [money] NOT NULL

    ) ON [PRIMARY]

    GO

    --This script populates the table:

    INSERT INTO MySourceTable

    (YMDH, DSales)

    SELECT '2007040108',0.00 UNION ALL

    SELECT '2007040112',10134.00 UNION ALL

    SELECT '2007040112',1524.00 UNION ALL

    SELECT '2007040112',0.00 UNION ALL

    SELECT '2007040113',52817.00 UNION ALL

    SELECT '2007040113',47725.00 UNION ALL

    SELECT '2007040113',0.00 UNION ALL

    SELECT '2007040114',12486.00 UNION ALL

    SELECT '2007040114',1876.00 UNION ALL

    SELECT '2007040114',0.00 UNION ALL

    SELECT '2007040115',28014.00 UNION ALL

    SELECT '2007040115',1048.00 UNION ALL

    SELECT '2007040115',0.00 UNION ALL

    SELECT '2007040116',2588.00 UNION ALL

    SELECT '2007040116',0.00 UNION ALL

    SELECT '2007040117',58794.62 UNION ALL

    SELECT '2007040117',30618.00 UNION ALL

    SELECT '2007040117',0.00 UNION ALL

    SELECT '2007040118',356.00 UNION ALL

    SELECT '2007040118',0.00 UNION ALL

    SELECT '2007040119',2060.00 UNION ALL

    SELECT '2007040119',5506.00 UNION ALL

    SELECT '2007040119',0.00 UNION ALL

    SELECT '2007040120',1798.00 UNION ALL

    SELECT '2007040120',0.00 UNION ALL

    SELECT '2007040121',1152.00 UNION ALL

    SELECT '2007040121',416.00 UNION ALL

    SELECT '2007040122',556.00 UNION ALL

    SELECT '2007040122',0.00 UNION ALL

    SELECT '2007040123',0.00 UNION ALL

    SELECT '2007040124',707.00 UNION ALL

    SELECT '2007040124',0.00 UNION ALL

    SELECT '2007040201',178.00 UNION ALL

    SELECT '2007040203',0.00 UNION ALL

    SELECT '2007040204',336.00 UNION ALL

    SELECT '2007040207',1000.00 UNION ALL

    SELECT '2007040209',5130.00 UNION ALL

    SELECT '2007040209',0.00 UNION ALL

    SELECT '2007040210',31858.00 UNION ALL

    SELECT '2007040210',15480.00 UNION ALL

    SELECT '2007040210',0.00 UNION ALL

    SELECT '2007040211',18387.00 UNION ALL

    SELECT '2007040211',19650.00 UNION ALL

    SELECT '2007040211',0.00 UNION ALL

    SELECT '2007040212',94207.50 UNION ALL

    SELECT '2007040212',39860.75 UNION ALL

    SELECT '2007040212',0.00 UNION ALL

    SELECT '2007040213',54162.00 UNION ALL

    SELECT '2007040213',17391.00 UNION ALL

    SELECT '2007040213',0.00 UNION ALL

    SELECT '2007040214',43731.15 UNION ALL

    SELECT '2007040214',44529.10 UNION ALL

    SELECT '2007040214',0.00 UNION ALL

    SELECT '2007040215',65498.10 UNION ALL

    SELECT '2007040215',70817.00 UNION ALL

    SELECT '2007040215',0.00 UNION ALL

    SELECT '2007040216',38036.66 UNION ALL

    SELECT '2007040216',16014.00 UNION ALL

    SELECT '2007040216',0.00 UNION ALL

    SELECT '2007040217',37193.00 UNION ALL

    SELECT '2007040217',82849.48 UNION ALL

    SELECT '2007040217',0.00 UNION ALL

    SELECT '2007040218',52499.00 UNION ALL

    SELECT '2007040218',33346.90 UNION ALL

    SELECT '2007040218',0.00 UNION ALL

    SELECT '2007040219',30930.60 UNION ALL

    SELECT '2007040219',3696.00 UNION ALL

    SELECT '2007040219',0.00 UNION ALL

    SELECT '2007040220',39247.00 UNION ALL

    SELECT '2007040220',10326.00 UNION ALL

    SELECT '2007040220',0.00 UNION ALL

    SELECT '2007040221',2924.00 UNION ALL

    SELECT '2007040221',3002.00 UNION ALL

    SELECT '2007040221',0.00 UNION ALL

    SELECT '2007040222',1517.00 UNION ALL

    SELECT '2007040222',2346.00 UNION ALL

    SELECT '2007040222',0.00 UNION ALL

    SELECT '2007040223',1918.00 UNION ALL

    SELECT '2007040223',614.00 UNION ALL

    SELECT '2007040224',366.00 UNION ALL

    SELECT '2007040301',1758.00 UNION ALL

    SELECT '2007040302',1926.00 UNION ALL

    SELECT '2007040303',4627.00 UNION ALL

    SELECT '2007040304',11448.00 UNION ALL

    SELECT '2007040306',278.00 UNION ALL

    SELECT '2007040307',118.00 UNION ALL

    SELECT '2007040309',14194.20 UNION ALL

    SELECT '2007040309',7812.00 UNION ALL

    SELECT '2007040309',0.00 UNION ALL

    SELECT '2007040310',26890.00 UNION ALL

    SELECT '2007040310',6982.00 UNION ALL

    SELECT '2007040310',0.00 UNION ALL

    SELECT '2007040311',62505.00 UNION ALL

    SELECT '2007040311',9022.00 UNION ALL

    SELECT '2007040311',0.00 UNION ALL

    SELECT '2007040312',44152.00 UNION ALL

    SELECT '2007040312',41157.12 UNION ALL

    SELECT '2007040312',0.00 UNION ALL

    SELECT '2007040313',58767.00 UNION ALL

    SELECT '2007040313',45896.00 UNION ALL

    SELECT '2007040313',0.00 UNION ALL

    SELECT '2007040314',69632.72 UNION ALL

    SELECT '2007040314',57018.86 UNION ALL

    SELECT '2007040314',0.00 UNION ALL

    SELECT '2007040315',20793.00 UNION ALL

    SELECT '2007040315',15315.00 UNION ALL

    SELECT '2007040315',0.00 UNION ALL

    SELECT '2007040316',33963.00 UNION ALL

    SELECT '2007040316',38595.00 UNION ALL

    SELECT '2007040316',0.00 UNION ALL

    SELECT '2007040317',49810.90 UNION ALL

    SELECT '2007040317',9616.00 UNION ALL

    SELECT '2007040317',0.00 UNION ALL

    SELECT '2007040318',49608.00 UNION ALL

    SELECT '2007040318',30082.00 UNION ALL

    SELECT '2007040318',0.00 UNION ALL

    SELECT '2007040319',40716.88 UNION ALL

    SELECT '2007040319',19256.32 UNION ALL

    SELECT '2007040319',0.00 UNION ALL

    SELECT '2007040320',16894.00 UNION ALL

    SELECT '2007040320',11448.00 UNION ALL

    SELECT '2007040320',0.00 UNION ALL

    SELECT '2007040321',41414.00 UNION ALL

    SELECT '2007040321',12660.00 UNION ALL

    SELECT '2007040321',0.00 UNION ALL

    SELECT '2007040322',2596.00 UNION ALL

    SELECT '2007040322',814.00 UNION ALL

    SELECT '2007040322',0.00 UNION ALL

    SELECT '2007040323',0.00 UNION ALL

    SELECT '2007040324',336.00 UNION ALL

    SELECT '2007040324',0.00 UNION ALL

    SELECT '2007040401',810.00 UNION ALL

    SELECT '2007040403',2000.00 UNION ALL

    SELECT '2007040405',1356.00 UNION ALL

    SELECT '2007040409',1150.00 UNION ALL

    SELECT '2007040409',0.00 UNION ALL

    SELECT '2007040410',20335.00 UNION ALL

    SELECT '2007040410',16036.00 UNION ALL

    SELECT '2007040410',0.00 UNION ALL

    SELECT '2007040411',38437.98 UNION ALL

    SELECT '2007040411',14888.00 UNION ALL

    SELECT '2007040411',0.00 UNION ALL

    SELECT '2007040412',20652.14 UNION ALL

    SELECT '2007040412',11131.00 UNION ALL

    SELECT '2007040412',0.00 UNION ALL

    SELECT '2007040413',50328.30 UNION ALL

    SELECT '2007040413',11344.00 UNION ALL

    SELECT '2007040413',0.00 UNION ALL

    SELECT '2007040414',25290.00 UNION ALL

    SELECT '2007040414',25558.00 UNION ALL

    SELECT '2007040414',0.00 UNION ALL

    SELECT '2007040415',17586.00 UNION ALL

    SELECT '2007040415',11322.00 UNION ALL

    SELECT '2007040415',0.00 UNION ALL

    SELECT '2007040416',45416.00 UNION ALL

    SELECT '2007040416',11679.10 UNION ALL

    SELECT '2007040416',0.00 UNION ALL

    SELECT '2007040417',33678.00 UNION ALL

    SELECT '2007040417',8343.00 UNION ALL

    SELECT '2007040417',0.00 UNION ALL

    SELECT '2007040418',53404.00 UNION ALL

    SELECT '2007040418',16272.00 UNION ALL

    SELECT '2007040418',0.00 UNION ALL

    SELECT '2007040419',4391.00 UNION ALL

    SELECT '2007040419',47856.00 UNION ALL

    SELECT '2007040419',0.00 UNION ALL

    SELECT '2007040420',2500.00 UNION ALL

    SELECT '2007040420',12222.00 UNION ALL

    SELECT '2007040420',0.00 UNION ALL

    SELECT '2007040421',10330.00 UNION ALL

    SELECT '2007040421',550.00 UNION ALL

    SELECT '2007040421',0.00 UNION ALL

    SELECT '2007040422',2078.00 UNION ALL

    SELECT '2007040422',0.00 UNION ALL

    SELECT '2007040423',316.00 UNION ALL

    SELECT '2007040423',0.00 UNION ALL

    SELECT '2007040424',434.00 UNION ALL

    SELECT '2007040502',0.00 UNION ALL

    SELECT '2007040506',11657.00 UNION ALL

    SELECT '2007040509',39.00 UNION ALL

    SELECT '2007040509',0.00 UNION ALL

    SELECT '2007040509',0.00 UNION ALL

    SELECT '2007040510',39093.00 UNION ALL

    SELECT '2007040510',6152.00 UNION ALL

    SELECT '2007040510',0.00 UNION ALL

    SELECT '2007040511',3106.00 UNION ALL

    SELECT '2007040511',14410.00 UNION ALL

    SELECT '2007040511',0.00 UNION ALL

    SELECT '2007040512',16256.00 UNION ALL

    SELECT '2007040512',12138.00 UNION ALL

    SELECT '2007040512',0.00 UNION ALL

    SELECT '2007040513',7233.00 UNION ALL

    SELECT '2007040513',9068.00 UNION ALL

    SELECT '2007040513',0.00 UNION ALL

    SELECT '2007040514',5732.66 UNION ALL

    SELECT '2007040514',20884.10 UNION ALL

    SELECT '2007040514',0.00 UNION ALL

    SELECT '2007040515',39550.00 UNION ALL

    SELECT '2007040515',3150.00 UNION ALL

    SELECT '2007040515',0.00 UNION ALL

    SELECT '2007040516',16281.00 UNION ALL

    SELECT '2007040516',15215.00 UNION ALL

    SELECT '2007040516',0.00 UNION ALL

    SELECT '2007040517',21652.00 UNION ALL

    SELECT '2007040517',3410.00 UNION ALL

    SELECT '2007040517',0.00 UNION ALL

    SELECT '2007040518',11406.00 UNION ALL

    SELECT '2007040518',13461.00 UNION ALL

    SELECT '2007040518',0.00 UNION ALL

    SELECT '2007040519',32522.00 UNION ALL

    SELECT '2007040519',35618.00 UNION ALL

    SELECT '2007040519',0.00 UNION ALL

    SELECT '2007040520',16034.00 UNION ALL

    SELECT '2007040520',12034.00 UNION ALL

    SELECT '2007040520',0.00 UNION ALL

    SELECT '2007040521',1000.00 UNION ALL

    SELECT '2007040521',3466.00 UNION ALL

    SELECT '2007040521',0.00 UNION ALL

    SELECT '2007040522',11164.00 UNION ALL

    SELECT '2007040522',0.00 UNION ALL

    SELECT '2007040523',3124.00 UNION ALL

    SELECT '2007040524',0.00 UNION ALL

    SELECT '2007040601',356.00 UNION ALL

    SELECT '2007040607',672.00 UNION ALL

    SELECT '2007040609',9485.00 UNION ALL

    SELECT '2007040609',0.00 UNION ALL

    SELECT '2007040610',14741.00 UNION ALL

    SELECT '2007040610',13028.00 UNION ALL

    SELECT '2007040610',0.00 UNION ALL

    SELECT '2007040611',22998.00 UNION ALL

    SELECT '2007040611',26248.00 UNION ALL

    SELECT '2007040611',0.00 UNION ALL

    SELECT '2007040612',12765.00 UNION ALL

    SELECT '2007040612',41322.99 UNION ALL

    SELECT '2007040612',0.00 UNION ALL

    SELECT '2007040613',34215.00 UNION ALL

    SELECT '2007040613',29221.00 UNION ALL

    SELECT '2007040613',0.00 UNION ALL

    SELECT '2007040614',33815.00 UNION ALL

    SELECT '2007040614',25890.00 UNION ALL

    SELECT '2007040614',0.00 UNION ALL

    SELECT '2007040615',10796.00 UNION ALL

    SELECT '2007040615',11626.00 UNION ALL

    SELECT '2007040615',0.00 UNION ALL

    SELECT '2007040616',14447.00 UNION ALL

    SELECT '2007040616',33006.00 UNION ALL

    SELECT '2007040616',0.00 UNION ALL

    SELECT '2007040617',73076.00 UNION ALL

    SELECT '2007040617',18378.00 UNION ALL

    SELECT '2007040617',0.00 UNION ALL

    SELECT '2007040618',26278.00 UNION ALL

    SELECT '2007040618',8952.00 UNION ALL

    SELECT '2007040618',0.00 UNION ALL

    SELECT '2007040619',2124.00 UNION ALL

    SELECT '2007040619',1673.00 UNION ALL

    SELECT '2007040619',0.00 UNION ALL

    SELECT '2007040620',3524.00 UNION ALL

    SELECT '2007040620',1206.00 UNION ALL

    SELECT '2007040621',1456.00 UNION ALL

    SELECT '2007040621',988.00 UNION ALL

    SELECT '2007040622',2994.00 UNION ALL

    SELECT '2007040622',0.00 UNION ALL

    SELECT '2007040623',634.00 UNION ALL

    SELECT '2007040623',0.00 UNION ALL

    SELECT '2007040624',8430.00 UNION ALL

    SELECT '2007040624',0.00 UNION ALL

    SELECT '2007040701',11928.00 UNION ALL

    SELECT '2007040709',336.00 UNION ALL

    SELECT '2007040710',0.00 UNION ALL

    SELECT '2007040710',11134.00 UNION ALL

    SELECT '2007040710',0.00 UNION ALL

    SELECT '2007040711',4912.00 UNION ALL

    SELECT '2007040711',2316.00 UNION ALL

    SELECT '2007040711',0.00 UNION ALL

    SELECT '2007040712',10021.00 UNION ALL

    SELECT '2007040712',2500.00 UNION ALL

    SELECT '2007040712',0.00 UNION ALL

    SELECT '2007040713',5393.28 UNION ALL

    SELECT '2007040713',10780.00 UNION ALL

    SELECT '2007040713',0.00 UNION ALL

    SELECT '2007040714',14143.00 UNION ALL

    SELECT '2007040714',0.00 UNION ALL

    SELECT '2007040714',0.00 UNION ALL

    SELECT '2007040715',1548.00 UNION ALL

    SELECT '2007040715',4952.00 UNION ALL

    SELECT '2007040715',0.00 UNION ALL

    SELECT '2007040716',2547.00 UNION ALL

    SELECT '2007040716',2235.00 UNION ALL

    SELECT '2007040716',0.00 UNION ALL

    SELECT '2007040717',9336.00 UNION ALL

    SELECT '2007040717',1000.00 UNION ALL

    SELECT '2007040717',0.00 UNION ALL

    SELECT '2007040718',1798.00 UNION ALL

    SELECT '2007040718',1642.00 UNION ALL

    SELECT '2007040719',1778.00 UNION ALL

    SELECT '2007040719',0.00 UNION ALL

    SELECT '2007040720',2414.00 UNION ALL

    SELECT '2007040720',0.00 UNION ALL

    SELECT '2007040721',4550.00 UNION ALL

    SELECT '2007040722',6616.00 UNION ALL

    SELECT '2007040722',0.00 UNION ALL

    SELECT '2007040723',0.00 UNION ALL

    SELECT '2007040724',1086.00 UNION ALL

    SELECT '2007040801',576.00 UNION ALL

    SELECT '2007040803',1302.00 UNION ALL

    SELECT '2007040807',258.00 UNION ALL

    SELECT '2007040809',0.00 UNION ALL

    SELECT '2007040811',336.00 UNION ALL

    SELECT '2007040811',0.00 UNION ALL

    SELECT '2007040812',198.00 UNION ALL

    SELECT '2007040812',1384.00 UNION ALL

    SELECT '2007040812',0.00 UNION ALL

    SELECT '2007040813',4540.00 UNION ALL

    SELECT '2007040813',1248.00 UNION ALL

    SELECT '2007040813',0.00 UNION ALL

    SELECT '2007040814',0.00 UNION ALL

    SELECT '2007040815',6696.00 UNION ALL

    SELECT '2007040815',0.00 UNION ALL

    SELECT '2007040815',0.00 UNION ALL

    SELECT '2007040816',2312.00 UNION ALL

    SELECT '2007040816',2082.00 UNION ALL

    SELECT '2007040817',970.00 UNION ALL

    SELECT '2007040817',0.00 UNION ALL

    SELECT '2007040818',3402.00 UNION ALL

    SELECT '2007040818',0.00 UNION ALL

    SELECT '2007040819',0.00 UNION ALL

    SELECT '2007040820',276.00 UNION ALL

    SELECT '2007040820',991.00 UNION ALL

    SELECT '2007040821',79.00 UNION ALL

    SELECT '2007040822',436.00 UNION ALL

    SELECT '2007040823',674.00 UNION ALL

    SELECT '2007040824',2518.00 UNION ALL

    SELECT '2007040903',1186.00 UNION ALL

    SELECT '2007040903',868.00 UNION ALL

    SELECT '2007040908',1008.00 UNION ALL

    SELECT '2007040909',9978.00 UNION ALL

    SELECT '2007040909',1200.00 UNION ALL

    SELECT '2007040909',0.00 UNION ALL

    SELECT '2007040910',25973.50 UNION ALL

    SELECT '2007040910',5000.00 UNION ALL

    SELECT '2007040910',0.00 UNION ALL

    SELECT '2007040911',10525.00 UNION ALL

    SELECT '2007040911',26120.00 UNION ALL

    SELECT '2007040911',0.00 UNION ALL

    SELECT '2007040912',33994.55 UNION ALL

    SELECT '2007040912',51386.00 UNION ALL

    SELECT '2007040912',0.00 UNION ALL

    SELECT '2007040913',62676.04 UNION ALL

    SELECT '2007040913',13704.00 UNION ALL

    SELECT '2007040913',0.00 UNION ALL

    SELECT '2007040914',22269.02 UNION ALL

    SELECT '2007040914',36412.00 UNION ALL

    SELECT '2007040914',0.00 UNION ALL

    SELECT '2007040915',51991.00 UNION ALL

    SELECT '2007040915',18337.10 UNION ALL

    SELECT '2007040915',0.00 UNION ALL

    SELECT '2007040916',58083.00 UNION ALL

    SELECT '2007040916',21491.02 UNION ALL

    SELECT '2007040916',0.00 UNION ALL

    SELECT '2007040917',82213.00 UNION ALL

    SELECT '2007040917',42641.00 UNION ALL

    SELECT '2007040917',0.00 UNION ALL

    SELECT '2007040918',34161.90 UNION ALL

    SELECT '2007040918',33886.00 UNION ALL

    SELECT '2007040918',0.00 UNION ALL

    SELECT '2007040919',17803.00 UNION ALL

    SELECT '2007040919',6558.00 UNION ALL

    SELECT '2007040919',0.00 UNION ALL

    SELECT '2007040920',17090.98 UNION ALL

    SELECT '2007040920',18150.00 UNION ALL

    SELECT '2007040920',0.00 UNION ALL

    SELECT '2007040921',11916.00 UNION ALL

    SELECT '2007040921',14337.52 UNION ALL

    SELECT '2007040921',0.00 UNION ALL

    SELECT '2007040922',2454.00 UNION ALL

    SELECT '2007040922',1448.00 UNION ALL

    SELECT '2007040922',0.00 UNION ALL

    SELECT '2007040923',1030.00 UNION ALL

    SELECT '2007040923',1498.00 UNION ALL

    SELECT '2007040923',0.00 UNION ALL

    SELECT '2007041002',0.00 UNION ALL

    SELECT '2007041003',614.00 UNION ALL

    SELECT '2007041007',0.00 UNION ALL

    SELECT '2007041008',730.00 UNION ALL

    SELECT '2007041008',0.00 UNION ALL

    SELECT '2007041009',1045.00 UNION ALL

    SELECT '2007041009',100.00 UNION ALL

    SELECT '2007041009',0.00 UNION ALL

    SELECT '2007041010',42251.00 UNION ALL

    SELECT '2007041010',14057.00 UNION ALL

    SELECT '2007041010',0.00 UNION ALL

    SELECT '2007041011',36521.00 UNION ALL

    SELECT '2007041011',23454.42 UNION ALL

    SELECT '2007041011',0.00 UNION ALL

    SELECT '2007041012',58136.00 UNION ALL

    SELECT '2007041012',57513.00 UNION ALL

    SELECT '2007041012',0.00 UNION ALL

    SELECT '2007041013',30904.00 UNION ALL

    SELECT '2007041013',24101.00 UNION ALL

    SELECT '2007041013',0.00 UNION ALL

    SELECT '2007041014',55098.00 UNION ALL

    SELECT '2007041014',18456.00 UNION ALL

    SELECT '2007041014',0.00 UNION ALL

    SELECT '2007041015',56982.00 UNION ALL

    SELECT '2007041015',12258.00 UNION ALL

    SELECT '2007041015',0.00 UNION ALL

    SELECT '2007041016',82386.78 UNION ALL

    SELECT '2007041016',9719.00 UNION ALL

    SELECT '2007041016',0.00 UNION ALL

    SELECT '2007041017',72422.00 UNION ALL

    SELECT '2007041017',6105.00 UNION ALL

    SELECT '2007041017',0.00 UNION ALL

    SELECT '2007041018',42969.00 UNION ALL

    SELECT '2007041018',25572.00 UNION ALL

    SELECT '2007041018',0.00 UNION ALL

    SELECT '2007041019',29316.00 UNION ALL

    SELECT '2007041019',5578.00 UNION ALL

    SELECT '2007041019',0.00 UNION ALL

    SELECT '2007041020',48670.80 UNION ALL

    SELECT '2007041020',250.00 UNION ALL

    SELECT '2007041020',0.00 UNION ALL

    SELECT '2007041021',38097.00 UNION ALL

    SELECT '2007041021',0.00 UNION ALL

    SELECT '2007041022',3330.00 UNION ALL

    SELECT '2007041022',4416.00 UNION ALL

    SELECT '2007041022',0.00 UNION ALL

    SELECT '2007041023',1798.00 UNION ALL

    SELECT '2007041023',0.00 UNION ALL

    SELECT '2007041024',138.00 UNION ALL

    SELECT '2007041024',2218.00 UNION ALL

    SELECT '2007041024',0.00 UNION ALL

    SELECT '2007041102',8938.00 UNION ALL

    SELECT '2007041109',7686.00 UNION ALL

    SELECT '2007041109',158.00 UNION ALL

    SELECT '2007041109',0.00 UNION ALL

    SELECT '2007041110',31685.38 UNION ALL

    SELECT '2007041110',3402.00 UNION ALL

    SELECT '2007041110',0.00 UNION ALL

    SELECT '2007041111',12293.00 UNION ALL

    SELECT '2007041111',30770.00 UNION ALL

    SELECT '2007041111',0.00 UNION ALL

    SELECT '2007041112',32011.00 UNION ALL

    SELECT '2007041112',30011.00 UNION ALL

    SELECT '2007041112',0.00 UNION ALL

    SELECT '2007041113',86121.04 UNION ALL

    SELECT '2007041113',36343.90 UNION ALL

    SELECT '2007041113',0.00 UNION ALL

    SELECT '2007041114',11595.00 UNION ALL

    SELECT '2007041114',50080.00 UNION ALL

    SELECT '2007041114',0.00 UNION ALL

    SELECT '2007041115',35222.00 UNION ALL

    SELECT '2007041115',28441.00 UNION ALL

    SELECT '2007041115',0.00 UNION ALL

    SELECT '2007041116',36350.34 UNION ALL

    SELECT '2007041116',51996.00 UNION ALL

    SELECT '2007041116',0.00 UNION ALL

    SELECT '2007041117',20849.98 UNION ALL

    SELECT '2007041117',13658.00 UNION ALL

    SELECT '2007041117',0.00 UNION ALL

    SELECT '2007041118',7930.00 UNION ALL

    SELECT '2007041118',6550.95 UNION ALL

    SELECT '2007041118',0.00 UNION ALL

    SELECT '2007041119',59974.00 UNION ALL

    SELECT '2007041119',17364.20 UNION ALL

    SELECT '2007041119',0.00 UNION ALL

    SELECT '2007041120',28877.00 UNION ALL

    SELECT '2007041120',13885.56 UNION ALL

    SELECT '2007041120',0.00 UNION ALL

    SELECT '2007041121',1376.00 UNION ALL

    SELECT '2007041121',1922.00 UNION ALL

    SELECT '2007041121',0.00 UNION ALL

    SELECT '2007041122',100.00 UNION ALL

    SELECT '2007041122',0.00 UNION ALL

    SELECT '2007041124',3588.00 UNION ALL

    SELECT '2007041124',2790.00 UNION ALL

    SELECT '2007041201',2553.00 UNION ALL

    SELECT '2007041201',3170.00 UNION ALL

    SELECT '2007041201',0.00 UNION ALL

    SELECT '2007041202',2080.00 UNION ALL

    SELECT '2007041202',1942.00 UNION ALL

    SELECT '2007041202',0.00 UNION ALL

    SELECT '2007041204',534.00 UNION ALL

    SELECT '2007041209',23284.00 UNION ALL

    SELECT '2007041209',0.00 UNION ALL

    SELECT '2007041210',15028.00 UNION ALL

    SELECT '2007041210',10222.00 UNION ALL

    SELECT '2007041210',0.00 UNION ALL

    SELECT '2007041211',44328.32 UNION ALL

    SELECT '2007041211',1290.00 UNION ALL

    SELECT '2007041211',0.00 UNION ALL

    SELECT '2007041212',24314.00 UNION ALL

    SELECT '2007041212',13326.00 UNION ALL

    SELECT '2007041212',0.00 UNION ALL

    SELECT '2007041213',23564.00 UNION ALL

    SELECT '2007041213',41693.13 UNION ALL

    SELECT '2007041213',0.00 UNION ALL

    SELECT '2007041214',67547.00 UNION ALL

    SELECT '2007041214',42698.00 UNION ALL

    SELECT '2007041214',0.00 UNION ALL

    SELECT '2007041215',30020.00 UNION ALL

    SELECT '2007041215',15639.00 UNION ALL

    SELECT '2007041215',0.00 UNION ALL

    SELECT '2007041216',28005.00 UNION ALL

    SELECT '2007041216',46498.96 UNION ALL

    SELECT '2007041216',0.00 UNION ALL

    SELECT '2007041217',49327.20 UNION ALL

    SELECT '2007041217',4449.00 UNION ALL

    SELECT '2007041217',0.00 UNION ALL

    SELECT '2007041218',48160.10 UNION ALL

    SELECT '2007041218',21166.00 UNION ALL

    SELECT '2007041218',0.00 UNION ALL

    SELECT '2007041219',35072.00 UNION ALL

    SELECT '2007041219',11368.00 UNION ALL

    SELECT '2007041219',0.00 UNION ALL

    SELECT '2007041220',12966.00 UNION ALL

    SELECT '2007041220',14065.00 UNION ALL

    SELECT '2007041220',0.00 UNION ALL

    SELECT '2007041221',4976.00 UNION ALL

    SELECT '2007041221',0.00 UNION ALL

    SELECT '2007041222',1226.00 UNION ALL

    SELECT '2007041222',1364.00 UNION ALL

    SELECT '2007041222',0.00 UNION ALL

    SELECT '2007041223',545.00 UNION ALL

    SELECT '2007041223',603.00 UNION ALL

    SELECT '2007041223',0.00 UNION ALL

    SELECT '2007041224',554.00 UNION ALL

    SELECT '2007041301',118.00 UNION ALL

    SELECT '2007041307',0.00 UNION ALL

    SELECT '2007041309',5192.00 UNION ALL

    SELECT '2007041309',11829.00 UNION ALL

    SELECT '2007041309',0.00 UNION ALL

    SELECT '2007041310',12579.22 UNION ALL

    SELECT '2007041310',14382.00 UNION ALL

    SELECT '2007041310',0.00 UNION ALL

    SELECT '2007041311',26242.00 UNION ALL

    SELECT '2007041311',24199.00 UNION ALL

    SELECT '2007041311',0.00 UNION ALL

    SELECT '2007041312',34216.00 UNION ALL

    SELECT '2007041312',47422.00 UNION ALL

    SELECT '2007041312',0.00 UNION ALL

    SELECT '2007041313',80186.54 UNION ALL

    SELECT '2007041313',65939.68 UNION ALL

    SELECT '2007041313',0.00 UNION ALL

    SELECT '2007041314',68909.90 UNION ALL

    SELECT '2007041314',22800.00 UNION ALL

    SELECT '2007041314',0.00 UNION ALL

    SELECT '2007041315',80246.40 UNION ALL

    SELECT '2007041315',19772.00 UNION ALL

    SELECT '2007041315',0.00 UNION ALL

    SELECT '2007041316',122902.12 UNION ALL

    SELECT '2007041316',36581.00 UNION ALL

    SELECT '2007041316',0.00 UNION ALL

    SELECT '2007041317',75411.72 UNION ALL

    SELECT '2007041317',23982.50 UNION ALL

    SELECT '2007041317',0.00 UNION ALL

    SELECT '2007041318',26418.48 UNION ALL

    SELECT '2007041318',15980.00 UNION ALL

    SELECT '2007041318',0.00 UNION ALL

    SELECT '2007041319',33950.00 UNION ALL

    SELECT '2007041319',26946.00 UNION ALL

    SELECT '2007041319',0.00 UNION ALL

    SELECT '2007041320',18378.00 UNION ALL

    SELECT '2007041320',5198.00 UNION ALL

    SELECT '2007041320',0.00 UNION ALL

    SELECT '2007041321',5553.00 UNION ALL

    SELECT '2007041321',20209.00 UNION ALL

    SELECT '2007041321',0.00 UNION ALL

    SELECT '2007041322',1536.00 UNION ALL

    SELECT '2007041322',3424.00 UNION ALL

    SELECT '2007041322',0.00 UNION ALL

    SELECT '2007041323',1000.00 UNION ALL

    SELECT '2007041323',2891.00 UNION ALL

    SELECT '2007041323',0.00 UNION ALL

    SELECT '2007041324',3504.00 UNION ALL

    SELECT '2007041324',3262.00 UNION ALL

    SELECT '2007041401',1000.00 UNION ALL

    SELECT '2007041402',218.00 UNION ALL

    SELECT '2007041408',0.00 UNION ALL

    SELECT '2007041410',24546.66 UNION ALL

    SELECT '2007041410',1189.00 UNION ALL

    SELECT '2007041411',750.00 UNION ALL

    SELECT '2007041411',5049.00 UNION ALL

    SELECT '2007041411',0.00 UNION ALL

    SELECT '2007041412',25077.00 UNION ALL

    SELECT '2007041412',1000.00 UNION ALL

    SELECT '2007041412',0.00 UNION ALL

    SELECT '2007041413',14938.00 UNION ALL

    SELECT '2007041413',29897.00 UNION ALL

    SELECT '2007041413',0.00 UNION ALL

    SELECT '2007041414',25814.86 UNION ALL

    SELECT '2007041414',5140.00 UNION ALL

    SELECT '2007041414',0.00 UNION ALL

    SELECT '2007041415',41367.00 UNION ALL

    SELECT '2007041415',6310.00 UNION ALL

    SELECT '2007041415',0.00 UNION ALL

    SELECT '2007041416',10078.00 UNION ALL

    SELECT '2007041416',1314.00 UNION ALL

    SELECT '2007041416',0.00 UNION ALL

    SELECT '2007041417',5180.00 UNION ALL

    SELECT '2007041417',10653.00 UNION ALL

    SELECT '2007041417',0.00 UNION ALL

    SELECT '2007041418',12078.00 UNION ALL

    SELECT '2007041418',28138.00 UNION ALL

    SELECT '2007041418',0.00 UNION ALL

    SELECT '2007041419',1216.00 UNION ALL

    SELECT '2007041419',0.00 UNION ALL

    SELECT '2007041421',2156.00 UNION ALL

    SELECT '2007041421',516.00 UNION ALL

    SELECT '2007041422',1766.00 UNION ALL

    SELECT '2007041423',2216.00 UNION ALL

    SELECT '2007041423',572.00 UNION ALL

    SELECT '2007041501',636.00 UNION ALL

    SELECT '2007041503',1642.00 UNION ALL

    SELECT '2007041507',1388.00 UNION ALL

    SELECT '2007041511',396.00 UNION ALL

    SELECT '2007041512',41701.00 UNION ALL

    SELECT '2007041512',158.00 UNION ALL

    SELECT '2007041512',0.00 UNION ALL

    SELECT '2007041513',4203.00 UNION ALL

    SELECT '2007041513',4000.00 UNION ALL

    SELECT '2007041513',0.00 UNION ALL

    SELECT '2007041514',21464.00 UNION ALL

    SELECT '2007041514',28750.00 UNION ALL

    SELECT '2007041514',0.00 UNION ALL

    SELECT '2007041515',12038.00 UNION ALL

    SELECT '2007041515',5614.00 UNION ALL

    SELECT '2007041515',0.00 UNION ALL

    SELECT '2007041516',98.00 UNION ALL

    SELECT '2007041516',4422.00 UNION ALL

    SELECT '2007041516',0.00 UNION ALL

    SELECT '2007041517',43233.46 UNION ALL

    SELECT '2007041517',44010.00 UNION ALL

    SELECT '2007041517',0.00 UNION ALL

    SELECT '2007041518',0.00 UNION ALL

    SELECT '2007041519',8506.00 UNION ALL

    SELECT '2007041520',3400.00 UNION ALL

    SELECT '2007041520',456.00 UNION ALL

    SELECT '2007041520',0.00 UNION ALL

    SELECT '2007041521',872.00 UNION ALL

    SELECT '2007041521',2620.00 UNION ALL

    SELECT '2007041524',0.00 UNION ALL

    SELECT '2007041524',552.00 UNION ALL

    SELECT '2007041601',616.00 UNION ALL

    SELECT '2007041606',2360.00 UNION ALL

    SELECT '2007041608',734.00 UNION ALL

    SELECT '2007041609',10028.00 UNION ALL

    SELECT '2007041609',1500.00 UNION ALL

    SELECT '2007041609',0.00 UNION ALL

    SELECT '2007041610',2720.00 UNION ALL

    SELECT '2007041610',19472.00 UNION ALL

    SELECT '2007041610',0.00 UNION ALL

    SELECT '2007041611',21774.74 UNION ALL

    SELECT '2007041611',7488.00 UNION ALL

    SELECT '2007041611',0.00 UNION ALL

    SELECT '2007041612',37588.00 UNION ALL

    SELECT '2007041612',6053.00 UNION ALL

    SELECT '2007041612',0.00 UNION ALL

    SELECT '2007041613',29119.95 UNION ALL

    SELECT '2007041613',12948.98 UNION ALL

    SELECT '2007041613',0.00 UNION ALL

    SELECT '2007041614',60317.00 UNION ALL

    SELECT '2007041614',22065.00 UNION ALL

    SELECT '2007041614',0.00 UNION ALL

    SELECT '2007041615',81225.76 UNION ALL

    SELECT '2007041615',40436.00 UNION ALL

    SELECT '2007041615',0.00 UNION ALL

    SELECT '2007041616',31532.00 UNION ALL

    SELECT '2007041616',41292.00 UNION ALL

    SELECT '2007041616',0.00 UNION ALL

    SELECT '2007041617',109903.56 UNION ALL

    SELECT '2007041617',61255.02 UNION ALL

    SELECT '2007041617',0.00 UNION ALL

    SELECT '2007041618',35375.00 UNION ALL

    SELECT '2007041618',3000.00 UNION ALL

    SELECT '2007041618',0.00 UNION ALL

    SELECT '2007041619',42584.00 UNION ALL

    SELECT '2007041619',16188.00 UNION ALL

    SELECT '2007041619',0.00 UNION ALL

    SELECT '2007041620',11560.00 UNION ALL

    SELECT '2007041620',4586.00 UNION ALL

    SELECT '2007041620',0.00 UNION ALL

    SELECT '2007041621',2496.00 UNION ALL

    SELECT '2007041621',2008.00 UNION ALL

    SELECT '2007041621',0.00 UNION ALL

    SELECT '2007041622',4936.00 UNION ALL

    SELECT '2007041622',0.00 UNION ALL

    SELECT '2007041623',3686.00 UNION ALL

    SELECT '2007041623',0.00 UNION ALL

    SELECT '2007041624',1000.00 UNION ALL

    SELECT '2007041701',0.00 UNION ALL

    SELECT '2007041703',1000.00 UNION ALL

    SELECT '2007041709',3000.00 UNION ALL

    SELECT '2007041709',0.00 UNION ALL

    SELECT '2007041710',28241.00 UNION ALL

    SELECT '2007041710',17966.00 UNION ALL

    SELECT '2007041710',0.00 UNION ALL

    SELECT '2007041711',24317.83 UNION ALL

    SELECT '2007041711',14589.83 UNION ALL

    SELECT '2007041711',0.00 UNION ALL

    SELECT '2007041712',17242.00 UNION ALL

    SELECT '2007041712',7083.00 UNION ALL

    SELECT '2007041712',0.00 UNION ALL

    SELECT '2007041713',20358.00 UNION ALL

    SELECT '2007041713',8885.40 UNION ALL

    SELECT '2007041713',0.00 UNION ALL

    SELECT '2007041714',36133.00 UNION ALL

    SELECT '2007041714',4798.00 UNION ALL

    SELECT '2007041714',0.00 UNION ALL

    SELECT '2007041715',92776.76 UNION ALL

    SELECT '2007041715',26450.00 UNION ALL

    SELECT '2007041715',0.00 UNION ALL

    SELECT '2007041716',26149.98 UNION ALL

    SELECT '2007041716',25286.00 UNION ALL

    SELECT '2007041716',0.00 UNION ALL

    SELECT '2007041717',19211.00 UNION ALL

    SELECT '2007041717',12125.00 UNION ALL

    SELECT '2007041717',0.00 UNION ALL

    SELECT '2007041718',11970.00 UNION ALL

    SELECT '2007041718',6858.00 UNION ALL

    SELECT '2007041718',0.00 UNION ALL

    SELECT '2007041719',3140.00 UNION ALL

    SELECT '2007041719',24819.00 UNION ALL

    SELECT '2007041719',0.00 UNION ALL

    SELECT '2007041720',10358.00 UNION ALL

    SELECT '2007041720',10608.00 UNION ALL

    SELECT '2007041720',0.00 UNION ALL

    SELECT '2007041721',14915.75 UNION ALL

    SELECT '2007041721',0.00 UNION ALL

    SELECT '2007041722',296.00 UNION ALL

    SELECT '2007041723',1864.00 UNION ALL

    SELECT '2007041723',0.00 UNION ALL

    SELECT '2007041801',396.00 UNION ALL

    SELECT '2007041801',0.00 UNION ALL

    SELECT '2007041802',1938.00 UNION ALL

    SELECT '2007041802',0.00 UNION ALL

    SELECT '2007041803',970.00 UNION ALL

    SELECT '2007041806',1750.00 UNION ALL

    SELECT '2007041808',0.00 UNION ALL

    SELECT '2007041809',36304.00 UNION ALL

    SELECT '2007041809',9882.00 UNION ALL

    SELECT '2007041809',0.00 UNION ALL

    SELECT '2007041810',22472.00 UNION ALL

    SELECT '2007041810',6758.00 UNION ALL

    SELECT '2007041810',0.00 UNION ALL

    SELECT '2007041811',25258.00 UNION ALL

    SELECT '2007041811',6629.92 UNION ALL

    SELECT '2007041811',0.00 UNION ALL

    SELECT '2007041812',17396.80 UNION ALL

    SELECT '2007041812',7780.00 UNION ALL

    SELECT '2007041812',0.00 UNION ALL

    SELECT '2007041813',27582.00 UNION ALL

    SELECT '2007041813',37906.78 UNION ALL

    SELECT '2007041813',0.00 UNION ALL

    SELECT '2007041814',68948.00 UNION ALL

    SELECT '2007041814',9030.00 UNION ALL

    SELECT '2007041814',0.00 UNION ALL

    SELECT '2007041815',30977.00 UNION ALL

    SELECT '2007041815',16666.00 UNION ALL

    SELECT '2007041815',0.00 UNION ALL

    SELECT '2007041816',51081.00 UNION ALL

    SELECT '2007041816',15458.00 UNION ALL

    SELECT '2007041816',0.00 UNION ALL

    SELECT '2007041817',27291.00 UNION ALL

    SELECT '2007041817',15444.00 UNION ALL

    SELECT '2007041817',0.00 UNION ALL

    SELECT '2007041818',28184.00 UNION ALL

    SELECT '2007041818',12738.25 UNION ALL

    SELECT '2007041818',0.00 UNION ALL

    SELECT '2007041819',16290.00 UNION ALL

    SELECT '2007041819',2900.00 UNION ALL

    SELECT '2007041819',0.00 UNION ALL

    SELECT '2007041820',2574.00 UNION ALL

    SELECT '2007041820',2198.00 UNION ALL

    SELECT '2007041820',0.00 UNION ALL

    SELECT '2007041821',8050.00 UNION ALL

    SELECT '2007041821',2932.00 UNION ALL

    SELECT '2007041821',0.00 UNION ALL

    SELECT '2007041822',2772.00 UNION ALL

    SELECT '2007041822',178.00 UNION ALL

    SELECT '2007041823',954.00 UNION ALL

    SELECT '2007041823',1000.00 UNION ALL

    SELECT '2007041824',1659.00 UNION ALL

    SELECT '2007041824',1506.00 UNION ALL

    SELECT '2007041824',0.00 UNION ALL

    SELECT '2007041901',3929.00 UNION ALL

    SELECT '2007041901',198.00 UNION ALL

    SELECT '2007041902',218.00 UNION ALL

    SELECT '2007041903',496.00 UNION ALL

    SELECT '2007041908',0.00 UNION ALL

    SELECT '2007041909',2872.00 UNION ALL

    SELECT '2007041909',0.00 UNION ALL

    SELECT '2007041910',18680.00 UNION ALL

    SELECT '2007041910',3336.00 UNION ALL

    SELECT '2007041910',0.00 UNION ALL

    SELECT '2007041911',10054.00 UNION ALL

    SELECT '2007041911',908.00 UNION ALL

    SELECT '2007041911',0.00 UNION ALL

    SELECT '2007041912',25728.34 UNION ALL

    SELECT '2007041912',10388.00 UNION ALL

    SELECT '2007041912',0.00 UNION ALL

    SELECT '2007041913',63719.59 UNION ALL

    SELECT '2007041913',6573.00 UNION ALL

    SELECT '2007041913',0.00 UNION ALL

    SELECT '2007041914',14790.00 UNION ALL

    SELECT '2007041914',13326.00 UNION ALL

    SELECT '2007041914',0.00 UNION ALL

    SELECT '2007041915',34948.00 UNION ALL

    SELECT '2007041915',5500.00 UNION ALL

    SELECT '2007041915',0.00 UNION ALL

    SELECT '2007041916',35014.88 UNION ALL

    SELECT '2007041916',20630.00 UNION ALL

    SELECT '2007041916',0.00 UNION ALL

    SELECT '2007041917',19209.75 UNION ALL

    SELECT '2007041917',14131.30 UNION ALL

    SELECT '2007041917',0.00 UNION ALL

    SELECT '2007041918',26297.00 UNION ALL

    SELECT '2007041918',13230.00 UNION ALL

    SELECT '2007041918',0.00 UNION ALL

    SELECT '2007041919',13959.00 UNION ALL

    SELECT '2007041919',1300.00 UNION ALL

    SELECT '2007041919',0.00 UNION ALL

    SELECT '2007041920',5918.00 UNION ALL

    SELECT '2007041920',2618.00 UNION ALL

    SELECT '2007041920',0.00 UNION ALL

    SELECT '2007041921',22548.00 UNION ALL

    SELECT '2007041921',12041.00 UNION ALL

    SELECT '2007041921',0.00 UNION ALL

    SELECT '2007041922',2738.00 UNION ALL

    SELECT '2007041922',1072.00 UNION ALL

    SELECT '2007041922',0.00 UNION ALL

    SELECT '2007041923',118.00 UNION ALL

    SELECT '2007041923',2100.00 UNION ALL

    SELECT '2007041923',0.00 UNION ALL

    SELECT '2007041924',4424.00 UNION ALL

    SELECT '2007041924',0.00 UNION ALL

    SELECT '2007042001',2739.00 UNION ALL

    SELECT '2007042001',0.00 UNION ALL

    SELECT '2007042002',356.00 UNION ALL

    SELECT '2007042002',0.00 UNION ALL

    SELECT '2007042005',1000.00 UNION ALL

    SELECT '2007042005',1050.00 UNION ALL

    SELECT '2007042006',0.00 UNION ALL

    SELECT '2007042007',8985.00 UNION ALL

    SELECT '2007042007',0.00 UNION ALL

    SELECT '2007042008',1742.00 UNION ALL

    SELECT '2007042009',150.00 UNION ALL

    SELECT '2007042009',1000.00 UNION ALL

    SELECT '2007042009',0.00 UNION ALL

    SELECT '2007042010',9950.50 UNION ALL

    SELECT '2007042010',7584.00 UNION ALL

    SELECT '2007042010',0.00 UNION ALL

    SELECT '2007042011',27988.00 UNION ALL

    SELECT '2007042011',56151.50 UNION ALL

    SELECT '2007042011',0.00 UNION ALL

    SELECT '2007042012',10080.00 UNION ALL

    SELECT '2007042012',15874.00 UNION ALL

    SELECT '2007042012',0.00 UNION ALL

    SELECT '2007042013',19175.00 UNION ALL

    SELECT '2007042013',34788.00 UNION ALL

    SELECT '2007042013',0.00 UNION ALL

    SELECT '2007042014',44437.00 UNION ALL

    SELECT '2007042014',5434.00 UNION ALL

    SELECT '2007042014',0.00 UNION ALL

    SELECT '2007042015',32590.38 UNION ALL

    SELECT '2007042015',26795.42 UNION ALL

    SELECT '2007042015',0.00 UNION ALL

    SELECT '2007042016',39047.00 UNION ALL

    SELECT '2007042016',19372.00 UNION ALL

    SELECT '2007042016',0.00 UNION ALL

    SELECT '2007042017',32002.00 UNION ALL

    SELECT '2007042017',3615.00 UNION ALL

    SELECT '2007042017',0.00 UNION ALL

    SELECT '2007042018',38282.00 UNION ALL

    SELECT '2007042018',16124.00 UNION ALL

    SELECT '2007042018',0.00 UNION ALL

    SELECT '2007042019',9425.00 UNION ALL

    SELECT '2007042019',4539.00 UNION ALL

    SELECT '2007042019',0.00 UNION ALL

    SELECT '2007042020',15870.00 UNION ALL

    SELECT '2007042020',2500.00 UNION ALL

    SELECT '2007042020',0.00 UNION ALL

    SELECT '2007042021',15115.36 UNION ALL

    SELECT '2007042021',1000.00 UNION ALL

    SELECT '2007042021',0.00 UNION ALL

    SELECT '2007042022',3704.00 UNION ALL

    SELECT '2007042023',2000.00 UNION ALL

    SELECT '2007042023',1000.00 UNION ALL

    SELECT '2007042101',1496.00 UNION ALL

    SELECT '2007042101',218.00 UNION ALL

    SELECT '2007042108',178.00 UNION ALL

    SELECT '2007042110',1594.00 UNION ALL

    SELECT '2007042110',0.00 UNION ALL

    SELECT '2007042111',14480.00 UNION ALL

    SELECT '2007042111',0.00 UNION ALL

    SELECT '2007042112',16092.00 UNION ALL

    SELECT '2007042112',0.00 UNION ALL

    SELECT '2007042113',300.00 UNION ALL

    SELECT '2007042113',0.00 UNION ALL

    SELECT '2007042114',1000.00 UNION ALL

    SELECT '2007042114',14676.00 UNION ALL

    SELECT '2007042114',0.00 UNION ALL

    SELECT '2007042115',1000.00 UNION ALL

    SELECT '2007042115',494.00 UNION ALL

    SELECT '2007042115',0.00 UNION ALL

    SELECT '2007042116',2254.00 UNION ALL

    SELECT '2007042116',7432.00 UNION ALL

    SELECT '2007042116',0.00 UNION ALL

    SELECT '2007042117',3693.00 UNION ALL

    SELECT '2007042117',1870.00 UNION ALL

    SELECT '2007042117',0.00 UNION ALL

    SELECT '2007042118',9489.00 UNION ALL

    SELECT '2007042118',0.00 UNION ALL

    SELECT '2007042118',0.00 UNION ALL

    SELECT '2007042119',8312.00 UNION ALL

    SELECT '2007042119',0.00 UNION ALL

    SELECT '2007042120',2300.00 UNION ALL

    SELECT '2007042123',1598.00 UNION ALL

    SELECT '2007042123',3164.00 UNION ALL

    SELECT '2007042123',0.00 UNION ALL

    SELECT '2007042124',327.00 UNION ALL

    SELECT '2007042124',0.00 UNION ALL

    SELECT '2007042201',910.00 UNION ALL

    SELECT '2007042201',0.00 UNION ALL

    SELECT '2007042202',7121.00 UNION ALL

    SELECT '2007042211',0.00 UNION ALL

    SELECT '2007042211',1190.00 UNION ALL

    SELECT '2007042211',0.00 UNION ALL

    SELECT '2007042212',2886.00 UNION ALL

    SELECT '2007042212',0.00 UNION ALL

    SELECT '2007042213',2658.00 UNION ALL

    SELECT '2007042213',0.00 UNION ALL

    SELECT '2007042214',2000.00 UNION ALL

    SELECT '2007042214',544.00 UNION ALL

    SELECT '2007042214',0.00 UNION ALL

    SELECT '2007042215',4440.00 UNION ALL

    SELECT '2007042215',3759.00 UNION ALL

    SELECT '2007042215',0.00 UNION ALL

    SELECT '2007042216',2542.00 UNION ALL

    SELECT '2007042216',0.00 UNION ALL

    SELECT '2007042217',4505.00 UNION ALL

    SELECT '2007042217',1208.00 UNION ALL

    SELECT '2007042217',0.00 UNION ALL

    SELECT '2007042218',5868.00 UNION ALL

    SELECT '2007042218',0.00 UNION ALL

    SELECT '2007042219',1046.00 UNION ALL

    SELECT '2007042219',494.00 UNION ALL

    SELECT '2007042219',0.00 UNION ALL

    SELECT '2007042220',374.00 UNION ALL

    SELECT '2007042220',1298.00 UNION ALL

    SELECT '2007042221',978.00 UNION ALL

    SELECT '2007042221',237.00 UNION ALL

    SELECT '2007042221',0.00 UNION ALL

    SELECT '2007042222',828.00 UNION ALL

    SELECT '2007042222',1008.00 UNION ALL

    SELECT '2007042222',0.00 UNION ALL

    SELECT '2007042223',992.00 UNION ALL

    SELECT '2007042224',1328.00 UNION ALL

    SELECT '2007042224',178.00 UNION ALL

    SELECT '2007042224',0.00 UNION ALL

    SELECT '2007042301',178.00 UNION ALL

    SELECT '2007042302',1090.00 UNION ALL

    SELECT '2007042303',5275.00 UNION ALL

    SELECT '2007042309',400.00 UNION ALL

    SELECT '2007042309',0.00 UNION ALL

    SELECT '2007042310',24661.00 UNION ALL

    SELECT '2007042310',2836.00 UNION ALL

    SELECT '2007042310',0.00 UNION ALL

    SELECT '2007042311',21984.00 UNION ALL

    SELECT '2007042311',16539.00 UNION ALL

    SELECT '2007042311',0.00 UNION ALL

    SELECT '2007042312',38988.00 UNION ALL

    SELECT '2007042312',43219.00 UNION ALL

    SELECT '2007042312',0.00 UNION ALL

    SELECT '2007042313',67965.00 UNION ALL

    SELECT '2007042313',25368.00 UNION ALL

    SELECT '2007042313',0.00 UNION ALL

    SELECT '2007042314',52976.02 UNION ALL

    SELECT '2007042314',12366.00 UNION ALL

    SELECT '2007042314',0.00 UNION ALL

    SELECT '2007042315',43583.06 UNION ALL

    SELECT '2007042315',6051.00 UNION ALL

    SELECT '2007042315',0.00 UNION ALL

    SELECT '2007042316',62611.00 UNION ALL

    SELECT '2007042316',51519.00 UNION ALL

    SELECT '2007042316',0.00 UNION ALL

    SELECT '2007042317',30503.33 UNION ALL

    SELECT '2007042317',17118.00 UNION ALL

    SELECT '2007042317',0.00 UNION ALL

    SELECT '2007042318',44699.00 UNION ALL

    SELECT '2007042318',40597.00 UNION ALL

    SELECT '2007042318',0.00 UNION ALL

    SELECT '2007042319',45356.94 UNION ALL

    SELECT '2007042319',14609.00 UNION ALL

    SELECT '2007042319',0.00 UNION ALL

    SELECT '2007042320',17807.40 UNION ALL

    SELECT '2007042320',15486.70 UNION ALL

    SELECT '2007042320',0.00 UNION ALL

    SELECT '2007042321',13769.36 UNION ALL

    SELECT '2007042321',790.00 UNION ALL

    SELECT '2007042321',0.00 UNION ALL

    SELECT '2007042322',930.00 UNION ALL

    SELECT '2007042322',1636.00 UNION ALL

    SELECT '2007042323',1642.00 UNION ALL

    SELECT '2007042324',1464.00 UNION ALL

    SELECT '2007042324',682.00 UNION ALL

    SELECT '2007042324',0.00 UNION ALL

    SELECT '2007042401',532.00 UNION ALL

    SELECT '2007042401',2196.00 UNION ALL

    SELECT '2007042402',2388.00 UNION ALL

    SELECT '2007042407',0.00 UNION ALL

    SELECT '2007042408',1246.00 UNION ALL

    SELECT '2007042408',0.00 UNION ALL

    SELECT '2007042409',1000.00 UNION ALL

    SELECT '2007042409',500.00 UNION ALL

    SELECT '2007042409',0.00 UNION ALL

    SELECT '2007042410',39192.00 UNION ALL

    SELECT '2007042410',21539.30 UNION ALL

    SELECT '2007042410',0.00 UNION ALL

    SELECT '2007042411',33156.00 UNION ALL

    SELECT '2007042411',906.00 UNION ALL

    SELECT '2007042411',0.00 UNION ALL

    SELECT '2007042412',23308.00 UNION ALL

    SELECT '2007042412',2371.00 UNION ALL

    SELECT '2007042412',0.00 UNION ALL

    SELECT '2007042413',19982.00 UNION ALL

    SELECT '2007042413',38028.00 UNION ALL

    SELECT '2007042413',0.00 UNION ALL

    SELECT '2007042414',42965.00 UNION ALL

    SELECT '2007042414',47598.00 UNION ALL

    SELECT '2007042414',0.00 UNION ALL

    SELECT '2007042415',90232.40 UNION ALL

    SELECT '2007042415',56286.00 UNION ALL

    SELECT '2007042415',0.00 UNION ALL

    SELECT '2007042416',55055.60 UNION ALL

    SELECT '2007042416',23180.30 UNION ALL

    SELECT '2007042416',0.00 UNION ALL

    SELECT '2007042417',51579.00 UNION ALL

    SELECT '2007042417',78619.00 UNION ALL

    SELECT '2007042417',0.00 UNION ALL

    SELECT '2007042418',38935.00 UNION ALL

    SELECT '2007042418',57190.00 UNION ALL

    SELECT '2007042418',0.00 UNION ALL

    SELECT '2007042419',44056.00 UNION ALL

    SELECT '2007042419',13626.00 UNION ALL

    SELECT '2007042419',0.00 UNION ALL

    SELECT '2007042420',42206.00 UNION ALL

    SELECT '2007042420',15200.60 UNION ALL

    SELECT '2007042420',0.00 UNION ALL

    SELECT '2007042421',9874.00 UNION ALL

    SELECT '2007042421',7114.00 UNION ALL

    SELECT '2007042421',0.00 UNION ALL

    SELECT '2007042422',4336.00 UNION ALL

    SELECT '2007042422',2102.00 UNION ALL

    SELECT '2007042422',0.00 UNION ALL

    SELECT '2007042423',356.00 UNION ALL

    SELECT '2007042423',0.00 UNION ALL

    SELECT '2007042424',1284.00 UNION ALL

    SELECT '2007042424',0.00 UNION ALL

    SELECT '2007042502',1150.00 UNION ALL

    SELECT '2007042503',5275.00 UNION ALL

    SELECT '2007042503',0.00 UNION ALL

    SELECT '2007042505',0.00 UNION ALL

    SELECT '2007042509',24220.00 UNION ALL

    SELECT '2007042509',1598.00 UNION ALL

    SELECT '2007042509',0.00 UNION ALL

    SELECT '2007042510',3355.00 UNION ALL

    SELECT '2007042510',1000.00 UNION ALL

    SELECT '2007042510',0.00 UNION ALL

    SELECT '2007042511',67788.95 UNION ALL

    SELECT '2007042511',8442.49 UNION ALL

    SELECT '2007042511',0.00 UNION ALL

    SELECT '2007042512',55070.24 UNION ALL

    SELECT '2007042512',31017.00 UNION ALL

    SELECT '2007042512',0.00 UNION ALL

    SELECT '2007042513',37571.79 UNION ALL

    SELECT '2007042513',7287.45 UNION ALL

    SELECT '2007042513',0.00 UNION ALL

    SELECT '2007042514',24640.00 UNION ALL

    SELECT '2007042514',23652.00 UNION ALL

    SELECT '2007042514',0.00 UNION ALL

    SELECT '2007042515',13710.78 UNION ALL

    SELECT '2007042515',14304.28 UNION ALL

    SELECT '2007042515',0.00 UNION ALL

    SELECT '2007042516',96980.98 UNION ALL

    SELECT '2007042516',16228.90 UNION ALL

    SELECT '2007042516',0.00 UNION ALL

    SELECT '2007042517',24992.00 UNION ALL

    SELECT '2007042517',30648.00 UNION ALL

    SELECT '2007042517',0.00 UNION ALL

    SELECT '2007042518',7004.00 UNION ALL

    SELECT '2007042518',5175.00 UNION ALL

    SELECT '2007042518',0.00 UNION ALL

    SELECT '2007042519',34998.38 UNION ALL

    SELECT '2007042519',20103.00 UNION ALL

    SELECT '2007042519',0.00 UNION ALL

    SELECT '2007042520',29076.00 UNION ALL

    SELECT '2007042520',1040.00 UNION ALL

    SELECT '2007042520',0.00 UNION ALL

    SELECT '2007042521',2437.00 UNION ALL

    SELECT '2007042521',0.00 UNION ALL

    SELECT '2007042522',1436.00 UNION ALL

    SELECT '2007042523',218.00 UNION ALL

    SELECT '2007042523',0.00 UNION ALL

    SELECT '2007042524',218.00 UNION ALL

    SELECT '2007042603',0.00 UNION ALL

    SELECT '2007042604',198.00 UNION ALL

    SELECT '2007042607',158.00 UNION ALL

    SELECT '2007042609',2313.00 UNION ALL

    SELECT '2007042609',0.00 UNION ALL

    SELECT '2007042610',3776.00 UNION ALL

    SELECT '2007042610',18534.00 UNION ALL

    SELECT '2007042610',0.00 UNION ALL

    SELECT '2007042611',24233.00 UNION ALL

    SELECT '2007042611',30490.00 UNION ALL

    SELECT '2007042611',0.00 UNION ALL

    SELECT '2007042612',26538.00 UNION ALL

    SELECT '2007042612',16716.00 UNION ALL

    SELECT '2007042612',0.00 UNION ALL

    SELECT '2007042613',27858.38 UNION ALL

    SELECT '2007042613',40044.38 UNION ALL

    SELECT '2007042613',0.00 UNION ALL

    SELECT '2007042614',54961.00 UNION ALL

    SELECT '2007042614',11398.00 UNION ALL

    SELECT '2007042614',0.00 UNION ALL

    SELECT '2007042615',24056.00 UNION ALL

    SELECT '2007042615',39944.00 UNION ALL

    SELECT '2007042615',0.00 UNION ALL

    SELECT '2007042616',27516.00 UNION ALL

    SELECT '2007042616',800.00 UNION ALL

    SELECT '2007042616',0.00 UNION ALL

    SELECT '2007042617',48338.00 UNION ALL

    SELECT '2007042617',23388.00 UNION ALL

    SELECT '2007042617',0.00 UNION ALL

    SELECT '2007042618',93457.00 UNION ALL

    SELECT '2007042618',27223.00 UNION ALL

    SELECT '2007042618',0.00 UNION ALL

    SELECT '2007042619',12319.02 UNION ALL

    SELECT '2007042619',18441.00 UNION ALL

    SELECT '2007042619',0.00 UNION ALL

    SELECT '2007042620',16502.00 UNION ALL

    SELECT '2007042620',2726.00 UNION ALL

    SELECT '2007042620',0.00 UNION ALL

    SELECT '2007042621',4000.00 UNION ALL

    SELECT '2007042621',12900.00 UNION ALL

    SELECT '2007042621',0.00 UNION ALL

    SELECT '2007042622',2476.00 UNION ALL

    SELECT '2007042622',558.00 UNION ALL

    SELECT '2007042623',1738.00 UNION ALL

    SELECT '2007042623',0.00 UNION ALL

    SELECT '2007042701',400.00 UNION ALL

    SELECT '2007042701',1782.00 UNION ALL

    SELECT '2007042705',1384.00 UNION ALL

    SELECT '2007042709',8338.00 UNION ALL

    SELECT '2007042709',21226.00 UNION ALL

    SELECT '2007042709',0.00 UNION ALL

    SELECT '2007042710',59326.16 UNION ALL

    SELECT '2007042710',6680.00 UNION ALL

    SELECT '2007042710',0.00 UNION ALL

    SELECT '2007042711',33720.00 UNION ALL

    SELECT '2007042711',8950.00 UNION ALL

    SELECT '2007042711',0.00 UNION ALL

    SELECT '2007042712',69150.00 UNION ALL

    SELECT '2007042712',37658.00 UNION ALL

    SELECT '2007042712',0.00 UNION ALL

    SELECT '2007042713',50787.18 UNION ALL

    SELECT '2007042713',33996.00 UNION ALL

    SELECT '2007042713',0.00 UNION ALL

    SELECT '2007042714',37795.00 UNION ALL

    SELECT '2007042714',38444.00 UNION ALL

    SELECT '2007042714',0.00 UNION ALL

    SELECT '2007042715',51292.00 UNION ALL

    SELECT '2007042715',3600.00 UNION ALL

    SELECT '2007042715',0.00 UNION ALL

    SELECT '2007042716',13527.00 UNION ALL

    SELECT '2007042716',66104.00 UNION ALL

    SELECT '2007042716',0.00 UNION ALL

    SELECT '2007042717',89041.96 UNION ALL

    SELECT '2007042717',21547.00 UNION ALL

    SELECT '2007042717',0.00 UNION ALL

    SELECT '2007042718',51159.34 UNION ALL

    SELECT '2007042718',34273.00 UNION ALL

    SELECT '2007042718',0.00 UNION ALL

    SELECT '2007042719',27738.00 UNION ALL

    SELECT '2007042719',11039.00 UNION ALL

    SELECT '2007042719',0.00 UNION ALL

    SELECT '2007042720',17802.00 UNION ALL

    SELECT '2007042720',23931.00 UNION ALL

    SELECT '2007042720',0.00 UNION ALL

    SELECT '2007042721',12430.00 UNION ALL

    SELECT '2007042721',11734.00 UNION ALL

    SELECT '2007042721',0.00 UNION ALL

    SELECT '2007042722',12086.00 UNION ALL

    SELECT '2007042722',0.00 UNION ALL

    SELECT '2007042722',0.00 UNION ALL

    SELECT '2007042723',661.00 UNION ALL

    SELECT '2007042801',0.00 UNION ALL

    SELECT '2007042804',1348.00 UNION ALL

    SELECT '2007042809',314.00 UNION ALL

    SELECT '2007042809',0.00 UNION ALL

    SELECT '2007042810',14530.00 UNION ALL

    SELECT '2007042810',700.00 UNION ALL

    SELECT '2007042810',0.00 UNION ALL

    SELECT '2007042811',1860.00 UNION ALL

    SELECT '2007042811',3112.00 UNION ALL

    SELECT '2007042811',0.00 UNION ALL

    SELECT '2007042812',3156.00 UNION ALL

    SELECT '2007042812',1000.00 UNION ALL

    SELECT '2007042812',0.00 UNION ALL

    SELECT '2007042813',18543.00 UNION ALL

    SELECT '2007042813',29508.00 UNION ALL

    SELECT '2007042813',0.00 UNION ALL

    SELECT '2007042814',28030.00 UNION ALL

    SELECT '2007042814',2506.00 UNION ALL

    SELECT '2007042814',0.00 UNION ALL

    SELECT '2007042815',4000.00 UNION ALL

    SELECT '2007042815',11432.00 UNION ALL

    SELECT '2007042815',0.00 UNION ALL

    SELECT '2007042816',8141.00 UNION ALL

    SELECT '2007042816',1270.00 UNION ALL

    SELECT '2007042816',0.00 UNION ALL

    SELECT '2007042817',26396.00 UNION ALL

    SELECT '2007042817',41766.00 UNION ALL

    SELECT '2007042817',0.00 UNION ALL

    SELECT '2007042818',17954.00 UNION ALL

    SELECT '2007042818',2000.00 UNION ALL

    SELECT '2007042818',0.00 UNION ALL

    SELECT '2007042819',3504.00 UNION ALL

    SELECT '2007042819',2000.00 UNION ALL

    SELECT '2007042820',7076.00 UNION ALL

    SELECT '2007042820',238.00 UNION ALL

    SELECT '2007042822',1188.00 UNION ALL

    SELECT '2007042822',0.00 UNION ALL

    SELECT '2007042823',2305.00 UNION ALL

    SELECT '2007042824',0.00 UNION ALL

    SELECT '2007042901',98.00 UNION ALL

    SELECT '2007042901',1408.00 UNION ALL

    SELECT '2007042901',0.00 UNION ALL

    SELECT '2007042903',821.00 UNION ALL

    SELECT '2007042904',674.00 UNION ALL

    SELECT '2007042906',115.00 UNION ALL

    SELECT '2007042909',0.00 UNION ALL

    SELECT '2007042910',0.00 UNION ALL

    SELECT '2007042912',22663.76 UNION ALL

    SELECT '2007042912',1574.00 UNION ALL

    SELECT '2007042912',0.00 UNION ALL

    SELECT '2007042913',943.00 UNION ALL

    SELECT '2007042913',2394.00 UNION ALL

    SELECT '2007042913',0.00 UNION ALL

    SELECT '2007042914',10858.00 UNION ALL

    SELECT '2007042914',13662.00 UNION ALL

    SELECT '2007042914',0.00 UNION ALL

    SELECT '2007042915',2532.00 UNION ALL

    SELECT '2007042915',12174.00 UNION ALL

    SELECT '2007042915',0.00 UNION ALL

    SELECT '2007042916',12300.00 UNION ALL

    SELECT '2007042916',3234.00 UNION ALL

    SELECT '2007042916',0.00 UNION ALL

    SELECT '2007042917',61226.00 UNION ALL

    SELECT '2007042917',50062.36 UNION ALL

    SELECT '2007042917',0.00 UNION ALL

    SELECT '2007042918',2048.00 UNION ALL

    SELECT '2007042919',0.00 UNION ALL

    SELECT '2007042920',2922.00 UNION ALL

    SELECT '2007042920',0.00 UNION ALL

    SELECT '2007042921',2536.00 UNION ALL

    SELECT '2007042921',200.00 UNION ALL

    SELECT '2007042922',2731.00 UNION ALL

    SELECT '2007042922',0.00 UNION ALL

    SELECT '2007042923',237.00 UNION ALL

    SELECT '2007042924',1158.00 UNION ALL

    SELECT '2007042924',2538.00 UNION ALL

    SELECT '2007043001',1820.00 UNION ALL

    SELECT '2007043005',968.00 UNION ALL

    SELECT '2007043009',1000.00 UNION ALL

    SELECT '2007043010',9088.00 UNION ALL

    SELECT '2007043010',39514.16 UNION ALL

    SELECT '2007043010',0.00 UNION ALL

    SELECT '2007043011',71617.20 UNION ALL

    SELECT '2007043011',26582.00 UNION ALL

    SELECT '2007043011',0.00 UNION ALL

    SELECT '2007043012',12716.00 UNION ALL

    SELECT '2007043012',66237.75 UNION ALL

    SELECT '2007043012',0.00 UNION ALL

    SELECT '2007043013',38206.00 UNION ALL

    SELECT '2007043013',20300.00 UNION ALL

    SELECT '2007043013',0.00 UNION ALL

    SELECT '2007043014',42631.00 UNION ALL

    SELECT '2007043014',53046.86 UNION ALL

    SELECT '2007043014',0.00 UNION ALL

    SELECT '2007043015',64987.64 UNION ALL

    SELECT '2007043015',59358.80 UNION ALL

    SELECT '2007043015',0.00 UNION ALL

    SELECT '2007043016',68935.16 UNION ALL

    SELECT '2007043016',1732.00 UNION ALL

    SELECT '2007043016',0.00 UNION ALL

    SELECT '2007043017',29874.10 UNION ALL

    SELECT '2007043017',49670.20 UNION ALL

    SELECT '2007043017',0.00 UNION ALL

    SELECT '2007043018',58962.44 UNION ALL

    SELECT '2007043018',24985.00 UNION ALL

    SELECT '2007043018',0.00 UNION ALL

    SELECT '2007043019',26054.28 UNION ALL

    SELECT '2007043019',35880.38 UNION ALL

    SELECT '2007043019',0.00 UNION ALL

    SELECT '2007043020',13513.10 UNION ALL

    SELECT '2007043020',26528.00 UNION ALL

    SELECT '2007043020',0.00 UNION ALL

    SELECT '2007043021',5580.00 UNION ALL

    SELECT '2007043021',0.00 UNION ALL

    SELECT '2007043022',0.00 UNION ALL

    SELECT '2007043023',1923.00 UNION ALL

    SELECT '2007043024',908.00 UNION ALL

    SELECT '2007043024',3514.00

    --Here is the code I am using to try to generate my output:

    SELECT CASE WHEN (GROUPING(MySourceTable.YMDH/100) = 1) THEN 'TOTAL'

    ELSE ISNULL(cast(MySourceTable.YMDH/100 AS CHAR (10)), 0) END AS YearMonthDay,

    CONVERT(varchar(30), convert(money, SUM(MySourceTable.Sales)),1) AS Sales

    From MySourceTable

    GROUP BY MySourceTable.YMDH/100 WITH ROLLUP

    --The above generates this error

    Server: Msg 8120, Level 16, State 1, Line 1

    Column 'MySourceTable.YMDH' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

    --The below query gives me what I want but...

    SELECT YMDH/100 AS YearMonthDay,

    CONVERT(varchar(30), convert(money, SUM(Sales)),1) AS Sales

    From MySourceTable

    GROUP BY YMDH/100 WITH ROLLUP

    --where Null is in the YearMonthDay column I want it to have 'TOTAL'

    --this is a report which is being generated to a web page and I need to return the values as I have shown here.

    I hope my explanation is clear enough -- thanks in advance for the help

  • [Code]

    SELECT CASE WHEN Total = 1 THEN 'TOTAL' ELSE CONVERT(varchar(10), YearMonthDay) END, Sales

    FROM (

    SELECT YMDH/100 AS YearMonthDay, GROUPING(MySourceTable.YMDH/100) AS Total,

    CONVERT(varchar(30), convert(money, SUM(Sales)),1) AS Sales

    From MySourceTable

    GROUP BY YMDH/100 WITH ROLLUP

    ) DT

    [/Code]

    _____________
    Code for TallyGenerator

  • Your awesome dude -- Thanks sooooo much!!!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply