User-523931540 posted
Hello there
I'm new to the site and I need your help on a topic. Thanks in advance for your help.
I do not know english, I use to google translate, I apologize if there is a translation error.
Operation gives incorrect result, what is the truth?
Could you help me.
I want to do
entering (g) - leaving (c) = remaining
Could you give me a code sample. Please
my table (sql express)

asp.net (remainingPage.aspx.cs)
if (!this.IsPostBack)
{
SqlDataSource SqlDataSource1 = new SqlDataSource();
SqlDataSource1.ID = "SqlDataSource1";
this.Page.Controls.Add(SqlDataSource1);
SqlDataSource1.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["connect"].ConnectionString;
SqlDataSource1.SelectCommand = "select s1.marka,s1.renkkodu,s1.renkadi, " +
"SUM(case when s1.yontem = 'g' then s1.kilo else 0 end) - SUM(case when s1.yontem = 'c' then s1.kilo else 0 end) as kilo" +
" from byh_boya_kalan_tbl s1" +
" group by s1.marka,s1.renkkodu,s1.renkadi order by s1.renkadi";
GridView1.DataSource = SqlDataSource1;
GridView1.DataBind();
}