Case when syntax in SQL statements and similar methods in Oracle

Source: Internet
Author: User

Case when syntax in SQL statements and similar methods in Oracle I. Basic Concepts and examples case when is the syntax of SQL statements, rather than the language www.2cto.com of a specific database I: select num, name, (case classnowhen '1' Class 1 'when' 2 'then' Class 2 'else' other classs' end) as classnamefrom student Method 2: select num, name, (case when classno = '1' then' Class 1 'when classno = '2' then' Class 2 'else' other class' end) as classname from student www.2cto.com 2. Other methods in Oracle 1. The decode function plays a similar role in Oracle select num, name, decode (classno, '1', 'class1 ', '2', 'second class', 'other class') as classname from student 2. if else in PL/SQL can also achieve this effect.

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.