avatar
求教:数据操作# Database - 数据库
z*a
1
想在DB2中实现以下数据操作,不知道是否有相应的Statement or Function:
Table A has 2 columns: c1 and c2. c1 already has data populated. c2 is empty.
I need to populate c2 with c1's data only when there's no duplicates. For
example: c1 has {a,a,b,c,c,d,e}. After running the SQL statement, c2 should be
populated with {"","",b,"","",d,e}. Is there any way to accomplish this?
Thanks for your help!
avatar
c*g
2
open a cursor.

【在 z****a 的大作中提到】
: 想在DB2中实现以下数据操作,不知道是否有相应的Statement or Function:
: Table A has 2 columns: c1 and c2. c1 already has data populated. c2 is empty.
: I need to populate c2 with c1's data only when there's no duplicates. For
: example: c1 has {a,a,b,c,c,d,e}. After running the SQL statement, c2 should be
: populated with {"","",b,"","",d,e}. Is there any way to accomplish this?
: Thanks for your help!

avatar
aw
3
没必要。
INSERT INTO T2
SELECT
CASE
WHEN value IN (SELECT value FROM T1 GROUP BY value HAVING COUNT(id)=1) THEN
value
ELSE ''
END
FROM
T1

empty.
should be

【在 c**g 的大作中提到】
: open a cursor.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。