问题标签 [teradata-sql-assistant]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
46 浏览

teradata - Teradata 以数字格式导出时间结果

Teradata 正在以数字格式而不是时间格式导出时间结果。例如:12:33 正在导出为 1233。但是,在 TeraData SQL 助手中显示结果时,格式是可以的。

0 投票
3 回答
249 浏览

sql - 计算行多列

我想根据多列和列中的特定值来计算行数。请检查附表。

计算以下值:

我试过了

COUNT(*) OVER (PARTITION BY ID, Date, Action = 'C') AS Count,但它没有用。你们中有人知道如何计算这个字段吗?

谢谢你。

在此处输入图像描述

0 投票
1 回答
41 浏览

sql - Querying the same table in the where clause


Known NTCV/COV can = '?' Or numeric value

Background The reason I use a max case when argument is to work how the database associates each Id with a type and each type may or may not have a numeric value. I dont want the data to have so many rows as there are other tables joined. For simplicity I'm only showing these 2. Further more the max case when argument allows the data to result as a row versus multiple rows.

Issue At times I might need to query for multiple scenarios where the NTVC = COV but I am unsure as to how to that in the where clause. If I try to write it as such it gives me an error. If I try to call the same table 3 times then it uses to much CPU and spools.

I am interested how you would rewrite this query in order to accomplish

Where ntvc = cov for expected results of sometimes 1m rows

Technology used: teradata sql assistant

0 投票
3 回答
68 浏览

sql - 如何使用 LIKE 将一个字段与另一个字段进行比较

我想要这样的东西:

但是,当我尝试此操作时,出现以下错误:

“5407:日期时间或间隔的无效操作”

我在 Terdata SQL Assistant 工作

0 投票
1 回答
43 浏览

sql - Continuous dates to create case #

I am trying to add case # based on Customer ID and Start & End Dates. As long as there is no break in the date ranges for a customer, same case # will be applied. See sample data. Is there way accomplish this in Teradata SQL?

data sample

0 投票
2 回答
1087 浏览

sql - Teradata 查询分页 - 每 1000 条记录批处理

我有这个 Teradata 查询:

此查询将生成一个 ID 列,结果将如下所示:

我想通过 1000 条记录将选择更改为批处理,如下所示:

感谢您的帮助。

0 投票
3 回答
39 浏览

sql - 将单元格值与该组中的最大值进行比较,出现错误 SELECT Failed 3707

我试图从视图中将单元格值与该组中的最大值进行比较,但它给了我一个错误。

内部查询运行良好,它为我提供了一份患者名单、他们的适应症以及 2017 年和 3 年索赔的数量。在外部查询中,我只需要保持耐心,并且只需要保持 2017 年索赔 > 0 并且在 3 年内拥有最大索赔的迹象。

代码在这里抛出错误

0 投票
1 回答
1511 浏览

sql - 不确定存储过程的正确语法

我正在处理我刚刚在这个站点上获得的一些其他代码,这是我第一次使用存储过程,所以我真的不确定语法应该如何工作。我在 Teradata SQL 助手工作。目标基本上是用这些变量创建一个宏。

我的问题是如何处理单引号?比如 case when 声明,这是一个问题,需要做一些不同的事情吗?

这很难,因为我没有得到任何结果或错误消息。只有“导入查询中找到的样式参数”的内容。

0 投票
0 回答
153 浏览

pivot-table - 在 Teradata SQL 版本 15.10.1.4 中使用 PIVOT 函数

我正在尝试旋转下表以使其成为一条记录。例子 :

表名 - ABC

在此处输入图像描述

我知道这可以通过案例陈述来完成。但是我有多个 item_id 的大约数百万条记录,所以我认为使用 case 语句会非常低效。

我希望结果是这样的 -

在此处输入图像描述

任何帮助,将不胜感激。谢谢!

0 投票
1 回答
71 浏览

powerbi - 避免在 Teradata SQL 中手动创建列

考虑以下名为“VIEW”的 Teradata 视图,它由事务数据组成。

DATE1 是过帐日期,DATE2 是交易的清算日期。WEEK1 和 WEEK2 分别是 DATE1 和 DATE2 的会计周。ATTR 是交易的随机属性。我需要按属性的“周”报告交易金额。

例如,对于 201901 周,我们希望查看 201901 周和之前的过帐日期以及 201901 之后的清算日期的交易金额。请参见下面的代码。

结果:

正如上面的代码所暗示的,我们必须每周手动创建我们希望避免的列。有没有办法在几周过去时动态创建这些列?还是有更好的方法来表示这一点?在报告中,使用 WEEK1 作为过滤器将过滤掉较早的几周(如果 WEEK1 为 201901,则 201852 将被过滤掉并丢失相应的数量)。我们最终将此 SQL 放入 PowerBI 仪表板。

谢谢!