SQL getting started Tutorial: SQL ROUND () instance tutorial

Source: Internet
Author: User

SQL getting started Tutorial: SQL ROUND () instance tutorial

Round () function
The round () function is used to specify Decimals in a numerical field.

Database round () syntax

SELECT ROUND(column_name,decimals) FROM table_name
Let's take a look at the data structure.
 
 
Parameter Description
column_name Required. The field to round.
decimals Required. Specifies the number of decimals to be returned.
Instance tutorial.
 
 
Id ProductName Unit UnitPrice
1 Jarlsberg 1000 g 10.45
2 Mascarpone 1000 g 32.56
3 Gorgonzola 1000 g 15.67

Now, we want to display the product name and price rounded to the nearest integer.

We use the following SELECT statement:

SELECT ProductName, ROUND(UnitPrice,0) as UnitPrice FROM Persons
 
Output result.
  
  
ProductName UnitPrice
Jarlsberg 10
Mascarpone 33
Gorgonzola 16

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.