我想办法在某个date_code中的不同列中添加多个金额,我已经使用了精选金额在一列中添加金额,但我不知道如何添加多列列,如果你明白我的意思,我的sql数据库如下:
Date amount1 amount2 amount3 amount4 amount5
02/10/2014 2 3 6 0 5
02/10/2014 3 1 2 0 3
02/10/2014 0 4 6 6 2
02/10/2014 2 0 9 3 6
02/10/2014 7 0 8 2 9
我需要在相同日期范围内的所有金额的总和。
总计将是:71
任何帮助都会很棒,
非常感谢, 皮特
这是我到目前为止所获得的代码,它增加了数量,但仅限于一列:
connect() cmd.CommandText = "SELECT SUM(amount1) FROM sqlccmbuildtimecount WHERE datevar = '" & temp_day & "/" & temp_month & "/" & temp_year & "'"
endvalue.Text = cmd.ExecuteScalar() disconnect()
我已将temp_day设置为" 02",temp_month设置为" 10"和temp_year到" 2014"
答案 0 :(得分:0)
总和不是71,应该是89
就像the_lotus说的那样,
做:
SELECT SUM(amount1) + SUM(amount2) + SUM(amount3) + SUM(amount4) + SUM(amount5) FROM sqlccmbuildtimecount WHERE datevar = '" & temp_day & "/" & temp_month & "/" & temp_year & "'"