SQL数据更新问题,高手来

来源:百度知道 编辑:UC知道 时间:2024/09/28 11:45:38
下面一个表
id code date
1 a x1
1 b y1
1 c z1
` ` `
2 a x2
2 b y1
2 c z2
` ` `
```````````
我要做的是让z1=x1+y1,z2=x2+y2,``````
要怎么做??
有没有给个简单的例子来参考一下!!
游标什么的不会用```
我打错了 是data 不是date
就是一个 int类型的数

update XXX set date=A.date from XXX left join (select id,sum(date) from XXX where code<>'c' group by id) as A on XXX.id=A.id where code='c'

你说得不清楚啊!

日期类型不能直接相加的

只能相减,得出来的日期是天(ORACLE中)

只能用游标,,去学一下游标。