Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Convert to from Period Table to daily forecast

Author  Topic 

Dandrikos
Starting Member

2 Posts

Posted - 2007-11-25 : 04:49:26
Hi,

I have one table that idicate periodical sales value.

Example: (day format is m/d/y)

Begin---------End--------------ExpSales
01/12/2007 - 05/12/2007--------- 10
03/12/2007 - 06/12/2007---------- 4

I need result below
Date-----------ExpSales
01/12/2007------10
02/12/2007------10
03/12/2007------14
04/12/2007------14
05/12/2007------14
06/12/2007------ 4


any suggeston vill be appreicated,




khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-11-25 : 07:13:48
[code]DECLARE @sample TABLE
(
[BEGIN] datetime,
[END] datetime,
ExpSales int
)
INSERT INTO @sample
SELECT '2007-12-01', '2007-12-05', 10 UNION ALL
SELECT '2007-12-03', '2007-12-06', 4

SELECT [DATE], ExpSales = SUM(ExpSales)
FROM F_TABLE_DATE('2007-12-01', '2007-12-10') d
INNER JOIN @sample s
ON [DATE] >= s.[BEGIN]
AND [DATE] <= s.[END]
GROUP BY [DATE]
ORDER BY [DATE]
/*
DATE ExpSales
----------- -----------
2007-12-01 10
2007-12-02 10
2007-12-03 14
2007-12-04 14
2007-12-05 14
2007-12-06 4

(6 row(s) affected)
*/
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Dandrikos
Starting Member

2 Posts

Posted - 2007-11-25 : 07:52:45
Thanks Wery much Khtan.

You offered me two info.
Solution And F_TABLE_DATE.
Before your respond I dont heared F_TABLE_DATE.

After your resposne I googled F_TABLE_DATE and get information about that.

thanks very much again.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-11-25 : 08:23:22
Actually you can just click on the F_TABLE_DATE in my post. It is linked to the source thread


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -