Common functions in SQL

Source: Internet
Author: User
Share some common functions in SQL to obtain the desired data at will. Www.ub2b.cn sorting and sharing without source code and Demonstration: the source code digital function ABS () calculates the absolute value (reminds me of the ABS anti-lock system), and rounds CEILING () to the maximum integer, -3.6 ROUND to-3 FLOOR () ROUND to the smallest integer,-3.6 ROUND to-4 ROUND () four homes five

Share some common functions in SQL to obtain the desired data at will. Http://www.ub2b.cn finishing sharing without source code and Demonstration: source code digital functions ABS () to find the absolute value (reminds me of the ABS anti lock system) CEILING () round to the maximum integer, -3.6 ROUND to-3 FLOOR () ROUND to the smallest integer,-3.6 ROUND to-4 ROUND () four homes five

Share some common functions in SQL to obtain the desired data at will.
Http://www.ub2b.cn sorting and sharing <无>

Source code and demo:Source code

The numeric function ABS () calculates the absolute value (reminds me of the ABS anti-lock system). CEILING () is rounded to the maximum integer, and-3.6 is rounded to-3 FLOOR () to the smallest integer, -3.6 rounding to-4 ROUND () Rounding, ROUND (3.141, 2) requires two parameters, the first is the operand, and the last is the precision string function LEN () convert string Length LOWER () to lowercase character UPPER () to uppercase character LTRIM () to left space RTRIM () to right space SUBSTRING (string, start_position, lenth) string truncation function, which starts from start_position. The length is lenth. The date function GETDATE () is used to obtain the current date DATEADD (datepart, number, date, datepart is the unit of measurement, and date is the date datepart to be operated. You can select year and quart. Er, month, dayofyear, day, week, weekday, hour, minute, secondDATEDIFF (datepart, startdate, enddate) calculate the difference between two dates based on datepart DATEPART (datepart, date) returns the specified part of the date to convert cast (expression as type) CONVERT (type, expression) null value processing function ISNULL (expression, value) to determine if expression is not empty return expression, otherwise, the return value of valueselect ISNULL (name, 'Alias name') from Person is similar to the switch case statement. CASE expressionWHEN value1 THEN return1WHEN value2 THEN return2ELSE return3END when the when is used for range determination, there can be no expression after case. The ROW_NUMBER () function is used to count the row number. ROW_NUMBER () is a window function. It cannot appear in where and can only appear in select or order. Select * from (select ROW_NUMBER () OVER (order by salary) as rownum, id, name, from Person) as e1where e1.rownum> 3 and e1.rownum <5

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.