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

How to use CASE statement when having multiple hierarchy picks - response (1) by dnoeth

$
0
0

Put a filter using ROW_NUMBER in a Derived Table and join to it:

SELECT *
FROM tab
QUALIFY
   ROW_NUMBER() 
   OVER (PARTITION BY LINE_ITEM
         ORDER BY 
            CASE STATUS_CODE 
               WHEN 'A' THEN 1  
               WHEN 'U' THEN 2 
               WHEN '1' THEN 3 
               WHEN 'G' THEN 4 
               WHEN 'F' THEN 5 
               WHEN 'E' THEN 6 
               WHEN 'L' THEN 7 
               WHEN 'C' THEN 8 
            END
        ) = 1

 


Viewing all articles
Browse latest Browse all 14773

Trending Articles



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