asp.net - Comparision of data available in one table using Select Query in asp -


respected members, have data 2 years in 1 sql table , populated gridview data (for 1 month) using select query command as

<asp:sqldatasource id="sqldatasource15" runat="server"          connectionstring="<%$ connectionstrings:punctualitymainconnectionstring2 %>"  selectcommand="select sum(case when dir_ind = 'dir' 1 else 0 end ) &quot;direct&quot;,   rly  punctualitymain     rly in ('cr', 'er', 'ecr', 'ecor', 'nr', 'ncr', 'ner', 'nfr', 'nwr', 'sr', 'scr', 'ser', 'secr', 'swr', 'wr', 'wcr') , date &gt;= '4/1/2012' , date &lt;= '4/30/2012'    group rly"></asp:sqldatasource> 

the gridview

rly  direct cr     5 er     7 ecr    2 

now, want display gridview comparative statement (month compared same month previous year) including %improvement / deterioration. thing this

rly    current month direct     previous month direct       %improvement / deterioration cr         5                         8                           37.5 er         7                         6                          -16.6 ecr        2                         2                            0.0 

is possible? if yes, please advise, how can achieved easily?

based upon our above discussion, may code t-sql query this:

select sum(case when dir_ind = 'dir' , date between '4/1/2012' , '4/30/2012' 1 else 0 end ) 'currentdirect',         sum(case when dir_ind = 'dir' , date between '3/1/2012' , '3/31/2012' 1 else 0 end ) 'previousdirect',         rly  punctualitymain    rly in ('cr', 'er', 'ecr', 'ecor', 'nr', 'ncr', 'ner', 'nfr', 'nwr', 'sr', 'scr', 'ser', 'secr', 'swr', 'wr', 'wcr')   , date >= '3/1/2012' , date <= '4/30/2012' group rly 

this way may set datasource of gridview resulted output. may calculate improvement , deterioration column in t-sql or in gridview's rowdatabound event.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -