插入多行数据
表1 Records
id objectid cost unitid dates
1 a 900.8 xx 2007-1-1
2 a 800.8 xx 2007-1-2
3 b 700.7 xx 2007-1-3
4 b 600.8 xx 2007-1-7
表2 budget
id objectid unit money
要将表1中的 objectid unitid sum(cost)按objectid分组插入到表2中
string strSQL = "insert into budget (objectid,unit_id,money) select Records.objectid,Records.unitid,(sum(Records.cost)) as mon from Records where Recordes.unitid= 'xx ' group by Records.objectid ";
这个语句正确吗?为什么不能插入到budget中.
------解决方案--------------------insert into budget(objectid,unitid,money) select objectid,unitid,sum(cost) as money from Records group by objectid,unitid