SQL math functions

Source: Internet
Author: User
Tags abs mathematical functions rtrim

-Mathematical functions
--abs Absolute Value
Select ABS (-7)
--ceiling Take the line
Select CEILING (3.14)
--Floor Remove line
Select Floor (4.14)
--power several parties
Select (2,3)
--round rounded integer part is odd even, fractional part. 5 is different.
Select Round (4.5,0)
--sqrt Open Square
Select sqrt (4)
--square Square
Select Square (2)


--String function
--ascii the ASCII code that returns the leftmost character of the string
Select ASCII (' name ')
Select ASCII (name) from biao--to view the ASCII code for the first character of the owner's name
--char convert ASCII code to characters
Select CHAR (70)
Select CHAR (Yuwen) from biao--converts all language fractions to acsii yards
--Note: (Must be an integer) the converted expression or constant needs to be between 0-255 and out of the output null
--len returns the length of the string
Select LEN (' ABCDEFG ')
Select LEN (name) from biao--displays the length of the name
--charindex returns a string of characters that appear in a string from the beginning to a few indexes
Select CHARINDEX (' EFG ', ' ABCDEFG ')--index starting at 1, if the return value is 0, indicates no
Select CHARINDEX (' 1993 ', birth) from studes--view in birthdays the index does not return a value of 0
--left means the string is truncated from the left
Select Left (' Abcdefgh ', 5)
--right to intercept the string from the right
Select Right (' Abcdefgh ', 5)
--lower Convert all to lowercase
Select lower (' Afagaag ')
--upper all converted to uppercase
Select Upper (' Afagaag ')
--ltrim Remove the left space
Select LTrim (' Aiiiji ')
--rtrim Remove the right space
Select RTrim (' Afjasjfioji ')
--patindex equivalent to Charindex returns the index bit of the first character in the string where the word string is located
Select Patindex ('%ghih% ', ' Kfjakjfajghihfiaosjfio ')
--replace Find and replace changes that do not make data just display the changes
Select replace (Sex, ' female ', ' girl ') from Studes
--replicate Copy and paste
Select Replicate (' ABC ', 3)
--reverse Flip
Select reverse (' AFAFAEFAEGEWG ')
--space spaces
Select ' A ' + space (+ ' AB ')
--STR cast to String
Select STR (222.2223,4,5)
--stuff
Select Stuff (' ADSFAF ', 4,2, ' RG ')
--substring intercepted string
Select substring (' Khdiofhiga ', 3,4)

Group BY is a grouping, used primarily for statistics, totals, and so on in SQL

Having is the condition

Order BY is sorted by what field, in order or in reverse.

In group BY, you can use the order by

Use order: GROUP by has order by

SQL math 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.