|
|
Archives of the TeradataForum
Message Posted: Thu, 08 Jun 2006 @ 18:41:32 GMT
Subj: | | Re: SQL to Normalize Columns to Rows |
|
From: | | Stegelmann, Rolf |
For my original post on the TABLE UDF it had the select wrong. The table having its parameters presented to the function has to be listed first
in the FROM clause. Then to avoid a Cartesian Join an equality where clause is added:
INSERT Customer_Number, Type_ID, Sales_Amount INTO T3
SELECT T2.Customer_Number, T2.Type_ID, T2.Sales_Amount
FROM T1, TABLE( expand(T1.Customer_number,
T1.col001,... T1.col125)) AS T2
WHERE T1.Customer_Number = T2.Customer_Number
;INSERT Customer_Number, Type_ID, Sales_Amount INTO T3
SELECT T2.Customer_Number, T2.Type_ID, T2.Sales_Amount
FROM T1, TABLE( expand(T1.Customer_number,
T1.col126, ... T1.col250)) AS T2
WHERE T1.Customer_Number = T2.Customer_Number;
| |