Skip to content
Advertisement

Create New SQL Column With Smaller Buckets (Based on Text, not Numbers)

I have a column in SQL that has multiple “Definitions” but I would like anything that starts with DEF to just be the generic “Definition”.

What can I put in my Select statement to have this converted?

Desired Output

Advertisement

Answer

You can use case:

select (case when current_output like 'DEF%' then 'DEFINITION'
             else current_output
        end) as desired_output
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement