Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

How to use CASE statement when having multiple hierarchy picks - forum topic by ASOORI15

$
0
0

Hello Experts,
I am  fairly new to Teradata and need help  to sort my issue.
I have a scenario where one line item has multiple status_codes. there is a hierarchy  preference set for these  status_codes to pick just one.
I have to use a Case statement(i think) to pick the appropriate Status_code for a given line item
Current situation:  there is a one to many relationship between LINE ITEM and STATUS CODE
FIX: I  have to get a ONE to ONE relationship between LINE_ITEM and STATUS_CODE. i.e if one line_item is assigned to multiple codes then pick the highest rank code in hierarchy.
EXAMPLE:
LINE_ITEM          STATUS_CODE
1234                          A
1234                          U
456                            G
1234                           F
567                             A
 
HIERARCHY given by business:
  Rank          Status_code

  1.             A
  2.             U
  3.             1
  4.             G
  5.             F
  6.             E
  7.             L
  8.             C

I would greatly appreciate for a quick solution.
Thanks,
AM

Forums: 

Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>