Options

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

  • Options

    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