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

Time:07-06

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

CodePudding user response:

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
  • Related