【发布时间】:2018-12-28 21:24:08
【问题描述】:
我的代码输出显示了两种不同的东西,根据代码没有意义。我会尽力说明,因为我似乎无法在引导模式下从我的计算机上传图片...
state cvmo unique_code total
IL 201701 95316 80,162.31
IL 201701 91304 21,315.69
IL 201,701 90035 63,989.21
IL 201701 96735 54,557.76
所以您可以看到 cvmo 列有两个不同的值 201701 和 201,701,我不知道为什么。我得到的 IL 总数的输出大约是应有的两倍,所以这让我想知道总数是否因此而乘以 2。此外,每个 unique_code 仅与 201701 或 201,701 配对。
我有一个成员表,其中 cvmo 直接取自数据库,并且都是 201701 的形式。
接下来,在总表上使用以下代码:
,case when extract(month from svc_from_dt) < 10
then trim(extract(year from svc_from_dt)) || '0' || trim(extract(month from svc_from_dt))
else trim(extract(year from svc_from_dt)) || trim(extract(month from svc_from_dt))
end as cvmo
/*This is also in the form 201701*/
上面的输出是在 cvmo 和唯一的成员键上加入成员表时得到的。
【问题讨论】:
-
所以你说你不想要
201,701。只需提供输入样本和所需的 o/p
标签: sql concatenation teradata sqldatatypes