Why subqueries in case are not working in teradata?
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.


Why subqueries in case are not working in... Expand / Collapse
Author
Message
Posted 5/8/2008 9:18:40 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 5/8/2008 9:02:52 AM
Posts: 2, Visits: 4
Please look at the query below

select
ename
from
emp e
where
not exists(select
'x'
from
dept d
where
d.deptno=case
when d.deptname in (select
deptname
from xdepartments
)
then
20
else
50
end
);


In the place of subquery "select deptname from xdepartments" , if I use hardcoded values like 100,200,3000 then it is working fine but I don't know why It is not working if I use subquery like above It's giving an error message..
Please Help me out...
I am using teradata SQL Assistant 7.1
and getting Error message as : Illegal expression in when clause of case expression.
Please help me out
Thanx

Regards,
jack


JACK
Post #11386
Posted 5/8/2008 9:47:52 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 8/11/2008 3:00:36 PM
Posts: 76, Visits: 147
hi,

WHEN search conditions cannot contain SELECT statements.
try using a derived table instead.

thx


-SN

Post #11387
Posted 5/8/2008 10:53:17 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 6/25/2008 7:26:06 AM
Posts: 474, Visits: 202
Hi Jack,
Teradata supports Scalar Subqueries only in some special cases within WHERE/HAVING.

You'll have to rewrite it to (Outer) Joins.

Dieter
Post #11391
« 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 1:19am

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.188. 7 queries. Compression Disabled.