Learn SQL Diary (ii)

Source: Internet
Author: User
Tags case statement

# # #. Using Functions in Query statements

@1. round (D1,D2) is used to round the number D1 to indicate the number of digits D2 after the decimal point (D2 does not write by default is 0)

@2. trunc (D1,D2) intercept the method of de-tail

@3. Date function sysdate

Select Sysdate from dual; ----Get the current time of the system

@4. Subtraction of date data, resulting in a number of days difference between two dates less than one day in decimal notation

@5. Months_between (d1,d2) get D1, d2 two date data difference between the month decimal representation

@6. Calculate the point in time before D2 months add_months (D1,D2) D1 as the date function D2 for the number of months

@7. Calculate the last day of this month Last_day (sysdate) from dual;

@8. Conversion function To_char (date data, format) converts date data into character data

Select To_char (sysdate, ' Yyyy-mm-dd hh24:mi:ss ') from dual;

Conversion function to_date () converts string data to date data in the specified format

@9. function coalesce (parameter list) returns the last value in the parameter list of the first non-null parameter in the argument list is usually a constant

The @10.case statement is the branch statement in the data that corresponds to the switch-case statement in Java

@11.decode function * *
The decode () function is a function in Oracle that is equivalent to a case-when statement in the same way as a case statement.    The Decode function syntax is as follows: Decode (judging condition, match 1, value 1, match 2, value 2, ..., default value) The meaning is: if the condition = match 1, then the reusing return value 1 to determine the condition = match 2, then Reusing return value 2

Learn SQL Diary (ii)

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.