Using INETERVAL With CASE Statement
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


Using INETERVAL With CASE Statement Expand / Collapse
Author
Message
Posted 7/31/2008 2:21:45 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: Yesterday @ 3:44:38 PM
Posts: 9, Visits: 32
Hello,

The following statement works if it is just a select

select case when grp_prpkg_exp_dt = '9999-12-31' then CAST('2007-12-31' AS DATE) - grp_prpkg_eff_dt
else grp_prpkg_exp_dt - grp_prpkg_eff_dt end as num
,grp_prpkg_eff_dt
from db_bidwd1v.dim_grp_prpkg_cvg
sample 5


but when I m trying to convert it to give me the number of months:

select case when grp_prpkg_exp_dt = '9999-12-31' then CAST('2007-12-31' AS DATE) - grp_prpkg_eff_dt MONTH(4)
else grp_prpkg_exp_dt - grp_prpkg_eff_dt MONTH(4) end as num
,grp_prpkg_eff_dt
from db_bidwd1v.dim_grp_prpkg_cvg
sample 5

It gives me error.

Can someone help me.

Thanks in advance.
Post #12405
Posted 7/31/2008 10:55:03 PM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Yesterday @ 4:46:44 AM
Posts: 134, Visits: 370
Hello,

What error you are getting?

Regards,

Adeel
Post #12409
Posted 8/1/2008 10:46:07 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: Yesterday @ 3:44:38 PM
Posts: 9, Visits: 32
It gives me syntax error saying that END should be there between grp_prpkg_eff_dt and MONTH
Post #12425
Posted 8/1/2008 11:52:08 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: PAC and SFT Members
Last Login: Today @ 10:56:35 AM
Posts: 298, Visits: 363
So add parentheses:

CASE WHEN grp_prpkg_exp_dt = '9999-12-31'
THEN (CAST('2007-12-31' AS DATE) - grp_prpkg_eff_dt MONTH(4))
ELSE (grp_prpkg_exp_dt - grp_prpkg_eff_dt MONTH(4))
END AS num
Post #12427
Posted 8/1/2008 1:15:21 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: Yesterday @ 3:44:38 PM
Posts: 9, Visits: 32
COOL.. Thanks
Post #12428
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 11:21pm

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.094. 9 queries. Compression Disabled.