sql round()

SQL Functions

homeBack

Next

SQL ROUND()

  • The ROUND() Function

    The ROUND() function is used to round a numeric field to the number of decimals specified.

    SQL ROUND() Syntax

    SELECT LEN(column_name) FROM table_name

    Parameter Description
    column_name Required. The field to round.
    decimals Required. Specifies the number of decimals to be returned.

  • SQL ROUND() Example

    Table Name ” Distance”

    Point distance(KM)
    AtoB 5.4
    XtoZ 15.7
    BtoE 4.9

    Now we want to display the Point and the Distance rounded to the nearest integer.

    We use the following SELECT statement:

    SELECT Point, ROUND(UnitPrice,0) as Unitdistance FROM Dictance

    The result-set will look like this:

    Point Unitdistance
    AtoB 5
    XtoZ 16
    BtoE 5

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s