Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to select rows with one of two column values can't be null?

For example:

hive> select mid, tag1, tag2, dt from message_use_tags where dt="20211107" and (tag1 != '' or tag2 != 'NULL') limit 50;

I want to specify:

  1. date = ‘20211107’

    MEDevel.com: Open-source for Healthcare and Education

    Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

    Visit Medevel

  2. tag1 and tag2 can’t be both empty string at the same time. One of them can be empty. However, the following doesn’t achieve the purpose:

    tag1 != ” or tag2 != ‘NULL’

In the result set, there are rows where both tag1 and tags are empty strings. How to modify the statement to get the results desired?

>Solution :

hive> select mid, tag1, tag2, dt from message_use_tags where dt="20211107" and (tag1 != '' or tag2 != 'NULL') and (tag1 != '' and tag2 != '') limit 50;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading