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

Apply lowercase in specific column for certain group of countries in BQ?

I need to apply lowercase to product_name column for countries like FR, ES, but for the rest of them CA, IL, DE should be without any changes. I’m tryin with this query, but something doesn’t work:

 SELECT
    id
    ,brand
    ,cern
    ,cern_3
    ,backpack
    ,qutoation
    ,product_name 
    ,CASE WHEN country_code in ('FR', 'ES') then lower(product_name) end
    ,category
    ,country_code
    ,timestamp
FROM table.name

>Solution :

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

Your query probably returns null for other countries, so as @forpas suggested in comments add else:

CASE WHEN country_code in ('FR', 'ES') then lower(product_name) else product_name end
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