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 ) "direct", rly punctualitymain rly in ('cr', 'er', 'ecr', 'ecor', 'nr', 'ncr', 'ner', 'nfr', 'nwr', 'sr', 'scr', 'ser', 'secr', 'swr', 'wr', 'wcr') , date >= '4/1/2012' , date <= '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
Post a Comment