Teradata 3848 and small int with COMPRESS

Viewed 30

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.

0 Answers
Related