General functions of the database (mathematical functions, String functions, other functions)

Source: Internet
Author: User
Tags mathematical functions

2 --Mathematical Functions3 Select CEILING(COUNT(*)/5.0) fromNews--take the smallest integer greater than the result4 Select  Floor(COUNT(*)/5.0) fromNews--take the largest integer less than the result5 Select SQRT(2)--Value Open Square6 Select ROUND(3.45645,2)7 Select ABS(-5): The absolute value function, which takes the absolute value of this number, can be applied to the addition and subtraction of some of the more chaotic values in the database. 8 9 --String FunctionsTen Select LOWER('RGFRG')--uppercase letters become lowercase One Select LOWER('GGFGRT')--lowercase letters into uppercase letters A Select LTRIM()--Remove the left word spaces lattice -  - Select RTRIM()--remove whitespace to the right of the string the Select  Left(Title,5) fromNews--the length of string to intercept from the left of a column - Select  Right(Title,5) fromNews--to intercept a string of more than one length from the right side of a column - Select SUBSTRING(Title,3,5) fromNews--To intercept a few characters from the first character in a column - Select REVERSE(Title) fromNews--Flip a column + Select CHARINDEX('China', Title) fromNews--the query target content does not appear in the specified area and where it appears - Select REPLACE(Title,'China','United States') fromNews--The replacement string. Example search keywords and clearly marked + Select STUFF(Title,3,4,'Chine') fromNews A Other Functions at Select CEILING(RAND()*Ten)--randomly generates a number between 1, which can be multiplied to increase the range of random numbers - Select LEN('Chine')--Take string length - Select GETDATE()--Get current Time - Select  Year(Sbirthday) fromStudent--year of taking time - Select Month(Sbirthday) fromStudent--Date Time Month - Select  Day(Sbirthday) fromStudent3--take the time of day in Select DatePart(Yy,sbirthday) fromStudent4--Yy,mm,dd, respectively, represents the month and day - Select CAST('123' as int)--Convert String

General functions of the database (mathematical functions, String functions, other functions)

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.