cancel
Showing results for 
Search instead for 
Did you mean: 

CASE Statement use in Select Statement

ishfaqad
Employee
Employee

Dear All,

Can we Use CASE Statement in SQL Query while "Creating View" with "SQL Query"...i.e...

SELECT v.FianaceYear, v.FinanceMonth ,FT.FinanceType_Eng, M.Description_en

,CASE WHEN v.tContractStatusId =3 and v.IsWriteOff IS NULL THEN 'Termianted'
WHEN v.tContractStatusId =3 and v.IsWriteOff=1 THEN 'Write Off - Termianted'
WHEN v.IsExpired =1 and v.IsWriteOff IS NULL THEN 'Expired'
WHEN v.IsExpired =1 and v.IsWriteOff=1 THEN 'Write Off - Expired'
WHEN v.tContractStatusId=1 and v.IsExpired =0 and v.IsWriteOff=1 THEN 'Write Off - Current'
ELSE 'Current' END ContractStatus
........


if we can use CASE in select statement...please help

3 REPLIES 3

RADSr
Captain
Captain

Yes - I just tested using this;

select
    *
CASE 
    WHEN Name = 'Jane' THEN 1 ELSE 2 END as CASEME
from
    _Rounding.rounding_csv
 
and it worked fine via SPARK SQL.
-- IncortaOne@PMsquare.com --

RADSr
Captain
Captain

Also w/ Postgres SQL   

RADSr_0-1665418783992.png

 

-- IncortaOne@PMsquare.com --

RADSr
Captain
Captain

But really, if you want to use SQL to build an Incorta view use the derived table => Incorta SQL option.   It's speedy.

RADSr_1-1665418925354.png

 

-- IncortaOne@PMsquare.com --