The Vertica Forum recently got a makeover! Let us know what you think by filling out this short, anonymous survey.
Please take this survey to help us learn more about how you use third party tools. Your input is greatly appreciated!

Outer query column reference in inner query case

Hi,
I am trying to write below query

Select *
From a
Where a.country="India" AND
A.language ="Hindi"
AND(case when (spoken = true AND exist(
select 1 from b
where b.country=a.country and
b.language=a.language
AND case when a.population >= b.populatiom)) then
True
Else
false
END)

it is not working, because we can't reference "a.population" outer query field in case expression of innerquery. I tried rewriting it wil OR caluse Vertica is not allowing it.

How can I re-write this

Comments

  • Not sure how to edit original post. Resubmitting the query by fixing the error

    Select *
    From a
    Where a.country="India" AND
    A.language ="Hindi"
    AND(case when (spoken = true AND exist(
    select 1 from b
    where b.country=a.country and
    b.language=a.language
    AND( case when (a.population >= b.population)) then
    True
    Else
    false
    END)) then
    true
    else
    false
    end)

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file