Comparison of decode and case when in oracle

Source: Internet
Author: User


Comparison of decode and case when in oracle the following example uses the decode of the emp table in oracle as follows: www.2cto.com DECODE (col | expression, search1, result1 [, search2, result2,...,] [, searchn, resultn,...,] [, default]) Example: SQL code select comm, decode (comm, 0, 'low', 300, 'low', 1400, 'high', 'average ') "testdecode" from emp; case when usage: CASE expr when then return_expr1 [when then return_expr2 when THEN return_exprn ELSE else_expr] END example: SQL code select comm, (case when comm = 0 then' very low 'when comm = 300 then' low 'when comm = 1400 then' high 'else' General 'end) "testcase" from emp; both methods of www.2cto.com can obtain the following results: COMM testcase ---------------------- -------- generally 300 low 500 generally 1400 high generally 0 very low generally

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.