请问各路大侠们 decode 函数的语法的用法~
顺便请举个列子,小妹十分谢谢~

解决方案 »

  1.   

    decode 在SQL Server中不支持,decode 在Oracle中用的吧!
      

  2.   

    case ...when ...then ...else
      

  3.   

    select decode(name,'你',1,0) FROM DUAL;
      

  4.   

    例子:
    select count(case ltrimrtrim((type)) when '1' then 1 else 0 end ) ,
    count(case ltrimrtrim((type)) when '2' then 1 else 0 end ) ,
    sum(case ltrimrtrim((type)) when '1' then cost else 0 end ) ,
    sum(case ltrimrtrim((type)) when '2' then cost else 0 end ) 
    from RECEIPT_TABLE
      

  5.   

    还是不很明白,汗ing~
    可否说明一下~怎么
    select count(case ltrimrtrim((type)) when '1' then 1 else 0 end ) ,
    count(case ltrimrtrim((type)) when '2' then 1 else 0 end ) ,
    sum(case ltrimrtrim((type)) when '1' then cost else 0 end ) ,
    sum(case ltrimrtrim((type)) when '2' then cost else 0 end ) 
    from RECEIPT_TABLE 都没见到 decode 这个函数
      

  6.   

    select count(case ltrim(rtrim(type)) when '1' then 1 else 0 end ) ,
    count(case ltrim(rtrim(type)) when '2' then 1 else 0 end ) ,
    sum(case ltrim(rtrim(type)) when '1' then cost else 0 end ) ,
    sum(case ltrim(rtrim(type)) when '2' then cost else 0 end ) 
    from RECEIPT_TABLE
      

  7.   

    SQL Server中没有trim(),只能把ltrim()和rtrim()合在一起用。
      

  8.   

    ENCODE(str,pass_str) 
    使用 pass_str 做为密钥加密 str。使用 DECODE() 解密结果。结果是一个与 string 一样长的二进制字符。如果希望将它保存到一个列中,请使用 BLOB 列类型。 DECODE(crypt_str,pass_str) 
    使用 pass_str 作为密钥解密加密后的字符串 crypt_str。crypt_str 应该是一个由 ENCODE() 返回的字符串。 这样的语法,可否举例稍稍说明一下哇,谢谢~~~~