Skip to content Skip to sidebar Skip to footer

Sql Returning Custom Values Based On Query Results

is it possible to make a query that returns a different custom value based on a query. its hard to explain, here is an example that should make it more clear. what I have in the ta

Solution 1:

You want a case statement. Depending on your flavor of SQL, something like this should work:

select 
    bar =casewhen foo =1then'one'when foo =2then'two'else'baz'endfrom myTable 

Solution 2:

Try

selectvalue=case t.value
               when1then'one'when2then'two'when3then'three'
               ...
               elsenullendfrom my_table t

Post a Comment for "Sql Returning Custom Values Based On Query Results"