Use of the CASE keyword in an Oracle SQL statement

Source: Internet
Author: User

Example 1:

A) double quotation marks are required for column names that begin with "_" in the Query column.

b) Use the "case" keyword to determine whether the pass is directly based on the score.

 create  table   Tbl_score (id  number  (4 ), -- id  name" Span style= "COLOR: #0000ff" >varchar2  (30 ), --  name  score number< /span> (3 ), --  fraction  otherscore number  (3 ) --  other scores ); 
Select  as "_id",         as name,         Case            when  then            ' Passing '           Else            ' inferior lattice '       End  as  ' Pass ',       
from Tbl_score t;

Example 2:

Returns values for different columns, depending on the situation.

Use the Tbl_score table above.

Select  as "_id",         as name,         Case            when  is NULL  Then             t.otherscore  -- can also return fixed value           else            T.score        End  as ' score '   from Tbl_score t;

Use of the CASE keyword in an Oracle SQL statement

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.