Search code examples
sqlselectfirebird

Query SELECT calculated column with condition


I need to create a column in my SELECT QUERY where it has a condition. Something like this:

SELECT NAME, ADDRESS, IF TABLE.COD=101 THEN return TABLE.VALUE AS TABLE  
FROM CRM

So the third argument in the SELECT is my calculated column with a condition.

I believe this is simple but I am not being successful on solving this.


Solution

  • As you have not provided any data and expected output, It is really difficult to figure out what you exactly want. still you can try below one.

    SELECT NAME, ADDRESS, (Case WHEN TABLE.COD=101 THEN TABLE.VALUE END) AS TABLE  
    FROM CRM