Archives of the TeradataForum
Message Posted: Thu, 18 Oct 2007 @ 10:14:01 GMT
I am new to Teradata but believe this is a general programming problem that isn't specific to Teradata but I need it to work in TD regardless.
I have my data in the following format:
*ITEM_ID ITEM_ATTRIBUTE* A 1 A 2 A 3 B 1 B 1 B 1 C 3 C 2 C 3
In this problem item attributes 2 and 3 and qualitatively different from 1, and I want to create an item level table that considers all the item attributes for a given item_id and summarises appropriately.
The logical consideration is as follows:
If item_attribute in (2,3) *only*, then 4 else if item_attribute in (1) *only* then 5 else 6;
The target output table would look like:
*ITEM_ID ITEM_SUMMARY_FLAG* A 6 B 5 C 4
Has anyone coded this kind of thing before? I tried coding this with nested IF and case statements but it doesn't seem to work. The only way I can get it to work is by creating multiple staging tables but I was hoping this could be programmed in a loop of some kind.
Any help would be greatly appreciated!
|Copyright 2016 - All Rights Reserved|
|Last Modified: 27 Dec 2016|