The following code works fine
My question is this (because I could not get the following code to work), is is possible to construct the case clause where the concat( ) is located inside the case statement, which would allow for multiple columns to be returned with just one case statement.
Here is my code that did not work.
The purpose of my question is to see if it possible to include several columns in one case statement rather than constructing one for each column I wish to output.
The practical application applies to a billing source reference. A job may be billed to the requesting party, the actual client or some 3rd party unique to that job.
Code:
select concat( case t1.testColumn when 'value1' then t1.column1 when 'value2' then t1.column2 when 'value3' then t1.column3 else t1.column4 end ) as outputColumn
Here is my code that did not work.
Code:
select case t1.testColumn when 'value1' then concat(t1.column1) as outputColumn1, concat(t1.column2) as outputColumn2, concat(t1.column3) as outputColumn3 when 'value2' then concat(t1.column4) as outputColumn1, concat(t1.column5) as outputColumn2, concat(t1.column6) as outputColumn3 else concat(t1.column7) as outputColumn1, concat(t1.column8) as outputColumn2, concat(t1.column9) as outputColumn3 end
The practical application applies to a billing source reference. A job may be billed to the requesting party, the actual client or some 3rd party unique to that job.
Comment