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.
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--------------ExpSales01/12/2007 - 05/12/2007--------- 1003/12/2007 - 06/12/2007---------- 4I need result belowDate-----------ExpSales01/12/2007------1002/12/2007------1003/12/2007------1404/12/2007------1405/12/2007------1406/12/2007------ 4any 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 @sampleSELECT '2007-12-01', '2007-12-05', 10 UNION ALLSELECT '2007-12-03', '2007-12-06', 4SELECT [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] |
 |
|
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. |
 |
|
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] |
 |
|
|
|
|
|
|