1

我有一个设置为金钱的 sql 列,小数点后有四个数字。我正在更新查询中计算此列,我想汇总此列。例如:2388.6796,应该是 2389

Math.Ceiling(0.5);
SqlCommand cmd1 = new SqlCommand("UPDATE Products SET [ThirdPartyRate] = 'Ceiling(" + GridView1.Rows[SelectedIndex].Cells[6].Text.ToString() + "' * [Price]) WHERE [Supplier] like '" + GridView1.Rows[SelectedIndex].Cells[0].Text.ToString() + "' ", con);
4

1 回答 1

1

采用:

CEILING ( numeric_expression )

原则上你会这样做:UPDATE TABLE Products SET rounded_val=CEILING(not_rounded_val);

SqlCommand cmd1 = new SqlCommand("UPDATE Products SET [ThirdPartyRate] = CEILING(" +
     GridView1.Rows[SelectedIndex].Cells[6].Text.ToString() + 
     " * [Price]) WHERE [Supplier] like '" + 
     GridView1.Rows[SelectedIndex].Cells[0].Text.ToString() + "' ", con);
于 2014-03-11T09:06:49.067 回答