Skip to Content
1
Nov 09, 2013 at 04:30 PM

Error using derived table and "case" block

282 Views

Hello my friends,

Does anyone know why this does not work?

select col1, col2,
"col3" =
case
when (select 'test' as colx) = 'test' then 'match'
else 'do not match'
end

from
(select 'x' as col1, 'y' as col2) as internal_table

The error says:

Could not execute statement.
The column 'col1' in the outer query is not present in the derived table
expression.
Sybase error code=11751
Severity Level=15, State=1, Transaction State=1
Line 9

1:select col1, col2,
2: "col3" =
3: case
4: when (select 'test' as colx) = 'test' then 'match'
5: else 'do not match'
6: end
7:
8:from
9: (select 'x' as col1, 'y' as col2) as internal_table

Thanks!

Marco