How can I SELECT multiple columns within a CASE WHEN on SQL Server?

前端 未结 4 606
一生所求
一生所求 2020-12-08 10:28

I have searched this site extensively but cannot find a solution.

Here is the example of my query:

SELECT 
   ActivityID,

   Hours = (CASE 
                 


        
4条回答
  •  借酒劲吻你
    2020-12-08 11:13

    "Case" can return single value only, but you can use complex type:

    create type foo as (a int, b text);
    select (case 1 when 1 then (1,'qq')::foo else (2,'ww')::foo end).*;
    

提交回复
热议问题