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 |
|
Sapereaud
Starting Member
3 Posts |
Posted - 2012-08-31 : 04:18:34
|
| Hi,I'm just putting together a simple moving average and moving standard deviation code, but for some reason the standard deviation wont calculate, all I get is zeros.I would much appreciate it if someone could point me in the right direction. The code: Where ID is an unique identifier SELECT A.ID, AVERAGE(A.[close]), STDEV(A.[close]) as STDFROM audtest.dbo.AUDJPY53 AS A CROSS JOIN audtest.dbo.AUDJPY53 AS BWHERE (A.ID >= 10) AND (A.ID BETWEEN B.ID AND B.ID + 9)GROUP BY A.IDORDER BY A.IDCheers,M |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-08-31 : 04:45:33
|
AVERAGE ? Are you using MS SQL Server ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
Sapereaud
Starting Member
3 Posts |
Posted - 2012-08-31 : 05:57:37
|
quote: Originally posted by khtan AVERAGE ? Are you using MS SQL Server ? KH[spoiler]Time is always against us[/spoiler]
Yep the 2012 version |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-08-31 : 06:31:37
|
the function name should still be AVG() in 2012.quote: but for some reason the standard deviation wont calculate, all I get is zeros
can you post some sample data and the expected result ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
Sapereaud
Starting Member
3 Posts |
Posted - 2012-08-31 : 06:49:32
|
| DataDate time ID close1993.05.16 18:00 1 78.161993.05.17 18:00 2 77.21993.05.18 18:00 3 76.661993.05.19 18:00 4 771993.05.20 18:00 5 76.91993.05.23 18:00 6 76.91993.05.24 18:00 7 76.61993.05.25 18:00 8 75.81993.05.26 18:00 9 74.41993.05.27 18:00 10 73.51993.05.30 18:00 11 72.71993.05.31 18:00 12 72.51993.06.01 18:00 13 72.61993.06.02 18:00 14 72.91993.06.03 18:00 15 72.81993.06.06 18:00 16 72.11993.06.07 18:00 17 71.21993.06.08 18:00 18 71.91993.06.09 18:00 19 71.71993.06.10 18:00 20 72.11993.06.13 18:00 21 70.91993.06.14 18:00 22 71.71993.06.15 18:00 23 72.21993.06.16 18:00 24 72.21993.06.17 18:00 25 74.31993.06.20 18:00 26 75.81993.06.21 18:00 27 75.81993.06.22 18:00 28 73.41993.06.23 18:00 29 72.51993.06.24 18:00 30 71.3ResultDate time ID close AVG STD1993.05.27 18:00 10 73.5 76.312 1.3903540721993.05.30 18:00 11 72.7 75.766 1.6346266991993.05.31 18:00 12 72.5 75.296 1.8393670411993.06.01 18:00 13 72.6 74.89 1.9496153471993.06.02 18:00 14 72.9 74.48 1.8866784451993.06.03 18:00 15 72.8 74.07 1.7423164661993.06.06 18:00 16 72.1 73.59 1.5234828521993.06.07 18:00 17 71.2 73.05 1.2747548781993.06.08 18:00 18 71.9 72.66 0.8733078881993.06.09 18:00 19 71.7 72.39 0.6690789691993.06.10 18:00 20 72.1 72.25 0.5461989871993.06.13 18:00 21 70.9 72.07 0.6650814491993.06.14 18:00 22 71.7 71.99 0.6556591261993.06.15 18:00 23 72.2 71.95 0.6258327791993.06.16 18:00 24 72.2 71.88 0.54119211993.06.17 18:00 25 74.3 72.03 0.9080504151993.06.20 18:00 26 75.8 72.4 1.5003703251993.06.21 18:00 27 75.8 72.86 1.7721299171993.06.22 18:00 28 73.4 73.01 1.7451201811993.06.23 18:00 29 72.5 73.09 1.6960411421993.06.24 18:00 30 71.3 73.01 1.765376888 |
 |
|
|
|
|
|
|
|