We're Moving!

The Vertica Forum is moving to a new OpenText Analytics Database (Vertica) Community.

Join us there to post discussion topics, learn about

product releases, share tips, access the blog, and much more.

Create My New Community Account Now


Outer query column reference in inner query case — Vertica Forum

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