如何在MSSQL服务器中使用ORACLE DECODE()?

时间:2013-10-01 09:35:16

标签: sql-server oracle date decode

如何将以下查询迁移到mssql服务器中我在此迁移中遇到了很多..帮助将不胜感激..

select FEES,
DECODE(SUBCOM_TYPE ,'S','SPECIAL COMMISSION','D','DEFAULT COMMISSION') AS SUBCOM_TYPE,
TO_CHAR(FROMDATE,'DD-MON-YYYY') AS FROMDATE, 
TO_CHAR(TODATE,'DD-MON-YYYY') AS TODATE,
TO_CHAR(ADDEDDATE,'DD-MON-YYYY') AS ADDEDDATE,
USER_CODE from COMMISSION 
where INST_ID = 'ABC' AND MASTERCODE='106'

1 个答案:

答案 0 :(得分:2)

您可以使用CASE功能

Select .....
CASE SUBCOM_TYPE
WHEN 'S' THEN 'SPECIAL COMMISION'
WHEN 'D' THEN 'DEFAULT COMMISION'
END