Detailed description of case expressions in Ruby and rubycase expressions

Source: Internet
Author: User

Detailed description of case expressions in Ruby and rubycase expressions

There are two forms of Ruby case expressions:

The first form is similar to a set of continuous if statements: it allows you to list a set of conditions and execute the first statement corresponding to the true condition expression.

In the second form, specify a target at the top of the case statement, and each when clause lists one or more comparison conditions.

Like if, case returns the value of the last expression to be executed. if the expression and condition are in the same row, the then keyword can be used to differentiate them.


In the Select Case X statement of a multi-branch statement, if the value of X is less than 10, what expression should be input after the Case condition?

Case Is <10

Briefly describe the usage of the CASE expression in SQL

Select
(Case when
To_char (sysdate, 'day ')
= 'Friday' then 10000
When
To_char (sysdate, 'day ')
= 'Saturday' then 8000
Else
5000
End) as Money
From dual
----------------------------------

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.