Need Case and Title included query

Database
Enthusiast

Need Case and Title included query

Hellow All,

 

Can any one please suggest how i can write the below query.

 

​(CASE WHEN PRC_M = 'PCNT' THEN DISC_PCT (TITLE 'DISC_PCT')(FORMAT 'ZZZZZZZZZZ9.99')  (CHAR(14))                                                        
           WHEN PRC_M = 'FIXD' THEN DISC_PCT(TITLE 'DISC_PCT') (FORMAT '$$$$$$$$$$9.99')  (CHAR(14))                                                             
      END) AS SUGGESTED_DISC_PCT​
 
 Actually above is statment want to differential the PERCENTAGE AND FIXED 
  WHEN WE ARE HAVING PRC_M IS FIXD THEN WE SHOULD KEEP $, 
  WHEN WE ARE HAVING PRC_M IS PRCN THEN WE SHOULD REMOVE THAT $
 
when i tried above script, i am getting error : like
 *** Failure 3707 Syntax error, expected something like an 'END' keyword between  the word 'DISC_PCT' and '('.
5 REPLIES
rjg
Supporter

Re: Need Case and Title included query

You'll need to remove  (TITLE 'DISC_PCT')
from your 'Then' statements.
The case statement will have SUGGESTED_DISC_PCT​ as it's title.
 
Rglass
Enthusiast

Re: Need Case and Title included query

Thanks RJG...

 

still am getting same error even though I have changed as below:

 

(CASE WHEN PRC_M = 'PCNT'
THEN DISC_PCT
(FORMAT 'ZZZZZZZZZZ9.99') (CHAR(14))
WHEN PRC_M = 'FIXD'
THEN DISC_PCT
(FORMAT '$$$$$$$$$$9.99') (CHAR(14))
END) AS DISC_PCT

Enthusiast

Re: Need Case and Title included query

the format of  CASE Statement is  The FORMAT and TITLE should come after in that order.

 

          (  CASE ... WHEN .... THEN  .... ELSE  ... END  )    ( FORMAT ..... )   (TITLE ' XYZ')

 

Make sure the THEN and ELSE part both return same data types.

 

Hope this helps

Enthusiast

Re: Need Case and Title included query

Is it possible to get different type in same data type in THEN and ELSE

Teradata Employee

Re: Need Case and Title included query

Not really.  Can you give an example of what you need?