sql server 2012 - Calculate daily use from running total in c# -
i have sql-table following columns , trying find way automatically calculate daily usage each entry. 'total usage' running total , there entry once per day per person. ultimately want able manipulate list in c# sql-query based method useful well. easy in excel hoping way automate it.... date | name | total usage | daily usage 2016-01-01 | john | 60 | ? 2016-01-02 | john | 63 | ? 2016-01-03 | john | 66 | ? 2016-01-01 | jane | 30 | ? 2016-01-02 | jane | 50 | ? 2016-01-03 | jane | 75 | ? pertinent question, can result table using following code snippet written in c#, utilizes system.data , system.data.sqlclient object library: strsql = "select [name], avg([total usage]) avrusage [yourtablename] group [name]"; // data table 2 columns: name , avgusage using (sqlconnection _connsql = new sqlconnection(connstring)) { using (sqlcommand _commandsql = new (sqlcommand()) ...