Teradata 3848和压缩的小int

发布于 2025-02-08 10:03:35 字数 1081 浏览 1 评论 0原文

我正在学习teradata,并在我联合两个查询时遇到了一个问题。我遇到的错误是错误3848,“子句的顺序必须只包含整数常数”。

我检查了表定义,并且我一直在检索的所有列都是很小的ints,除了使用3个从3开始使用的连续数字的压缩数。

SELECT
    COALESCE (ContractType, 'InvalidType') AS "Contract",
    COALESCE (ContractStatus, 'InvalidStatus') AS "Status",
    COUNT(ContractType) AS "Contract_Type_Count",
    COUNT (ContractStatus) AS "Contract_Status_Count"
    NULL AS "negCodeErr_count"
    FROM fund_inventory_db.ContractDetail
    GROUP BY CUBE (ContractType, ContractStatus)
    UNION
    NULL,
    NULL,
    NULL,
    NULL,
    SELECT COUNT(*)
    FROM fund_inventory_db.ContractDetail
    WHERE ContractSource = -2
    ORDER BY ContractType, ContractStatus;

所有这些字段的定义看起来像这样

[...columnName...] SMALLINT NOT NULL DEFAULT 0

:列,哪个是:

[...columnName...] SMALLINT NOT NULL DEFAULT 0 COMPRESS (3,4,5,6,7,8...)

使用这样的压缩是否使他们无法正常订购?如in,如果一列使用压缩(3,4,5,6,7 ...),而另一列则使用压缩(1,2,3,4,5 ...)或完全不使用压缩,则那会有所作为吗?

这可能令人尴尬,但是实际上可以使用一个查询使用Cube()的联盟吗?

抱歉,这对我来说是全新的,我的导师正在快速移动!我真诚地感谢您的时间。

I am learning Teradata and have run into an issue when I UNION two queries. The error I run into is error 3848, "The ORDER BY clause must contain only integer constants".

I checked the table definition and all the columns I have been retrieving are Small Ints with identical definitions, except for one which uses COMPRESS with a long series of consecutive numbers starting from 3.

SELECT
    COALESCE (ContractType, 'InvalidType') AS "Contract",
    COALESCE (ContractStatus, 'InvalidStatus') AS "Status",
    COUNT(ContractType) AS "Contract_Type_Count",
    COUNT (ContractStatus) AS "Contract_Status_Count"
    NULL AS "negCodeErr_count"
    FROM fund_inventory_db.ContractDetail
    GROUP BY CUBE (ContractType, ContractStatus)
    UNION
    NULL,
    NULL,
    NULL,
    NULL,
    SELECT COUNT(*)
    FROM fund_inventory_db.ContractDetail
    WHERE ContractSource = -2
    ORDER BY ContractType, ContractStatus;

The definitions for all those fields look like this:

[...columnName...] SMALLINT NOT NULL DEFAULT 0

Except for one column, which is:

[...columnName...] SMALLINT NOT NULL DEFAULT 0 COMPRESS (3,4,5,6,7,8...)

Does using COMPRESS like this make it possible that they are not able to order normally? As in, if one column uses COMPRESS(3,4,5,6,7...) and the other either uses COMPRESS (1,2,3,4,5...) or does not use COMPRESS at all, would that make a difference?

This might be embarrassing, but is it actually possible to use a UNION where one of the queries is using CUBE()?

Sorry, this is all new to me and my mentor is moving a little fast! I sincerely appreciate your time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文