0

I created table using VS2012, C#. I want to add column that calculates moving averages for Cclose column.

Below is my code to create the table

  string cmdText = "CREATE TABLE [" + TblName + "]"
                 + "(Tticker char(6),"
                 + "Pper char(1),"
                 + "Ddate date,"
                 + "Ttime TIME,"
                 + "Oopen float(6),"
                 + "Hhigh float(6),"
                 + "Llow float(6),"
                 + "Cclose float(6),"
                 + "Vvol char(15))";
  SqlCommand cmd = new SqlCommand(cmdText, con);
  cmd.ExecuteNonQuery();

I want to add column to calculate MV for last three Cclose values. Appreciate your support..thanks.

Adnan Al-Husain
  • 110
  • 1
  • 3
  • 17
  • 2
    This should be done with a view not in the table. – Ash Burlaczenko Jan 03 '13 at 20:43
  • Which version of SQL Server, please? Also, last three values based on which order? – Jon Seigel Jan 03 '13 at 23:05
  • Brother Ash Burlaczenko ,If you please add example or tut link. Brother Jon Seigel ,I'm new to this field,so I'll give all detail I think might support version detail..VS version.2012, with MS SQL server data file mdf located @App_Data folder. MS SQL Server Management Studio 2012 is installed with [Microsoft SQL Server Management Studio 11.0.2100.60]. Moving Average will calculate last three values in Cclose field ,table will be ordered by Ddate and Ttime fields.Thanks alot guys. – Adnan Al-Husain Jan 04 '13 at 06:26

0 Answers0