Search code examples
sqlwhere-clauseimpalasql-view

how to filter a record in where clause in impala query using conditional statements


Below is the sample data for reference

table 1

col1  col2
cmpy1 dev
cmpy1 testing
cmpy1 support
cmpy2 dev
cmpy2 testing
cmpy2 support
cmpy3 dev
cmpy3 testing
cmpy3 support

I will create a view table1_view on top of table1 in impala, the view should filter out the record like when col1 = 'cmpy1' and col2 in 'dev', so rest of records should populate in view when i do select * from table1_view.

Could someone help me in applying filter condition in where clause?


Solution

  • I will create a view table1_view on top of table1 in impala, the view should filter out the record like when col1 = 'cmpy1' and col2 in 'dev'

    Do you just want a where clause?

    create view table1_view as
    select col1, col2
    from table1 
    where not (col1 = 'cmpy1' and col2 = 'dev')