PostgreSQL Tutorial

  • Home
  • Stored Procedures
  • Triggers
  • Views
  • Interfaces
    • PostgreSQL PHP
    • PostgreSQL Python
    • PostgreSQL JDBC
  • Functions
    • Aggregate Functions
    • Date / Time Functions
    • String Functions
    • Math Functions
Home / PostgreSQL Math Functions

PostgreSQL Math Functions

This page provides you with the most commonly used PostgreSQL Math functions that help you perform various math operations quickly and effectively.

FunctionDescriptionExampleResult
ABSCalculate the absolute value of a numberABS(-10)10
CBRTCalculate the cube root of a numberCBRT(8)2
CEILRound a number up to the nearest integer, which is greater than or equal to numberCEIL(-12.8)-12
CEILINGSame as CEIL
DEGREESConvert radians to degreesDEGREES(0.8)45.83662361
DIVReturn the integer quotient of two numeric valuesDIV(8,3)2
EXPReturn the exponential value in scientific notation of a numberEXP(1)2.718281828
FLOORRound a number down to the nearest integer, which is less than or equal to numberFLOOR(10.6)10
LNReturn the natural logarithm of a numeric valueLN(3)1.098612289
LOGReturn the base 10 logarithm of a numeric valueLOG(1000)3
LOGReturn the logarithm of a numeric value to a specified baseLOG(2, 64)4
MODDivide the first parameter by the second one and return the remainderMOD(10,4)1
PIReturn the value of PIPI()3.141592654
POWERRaise a numeric value to the power of a second numeric valuePOWER(5, 3)125
RADIANSConvert degrees to radiansRADIANS(60)1.047197551
ROUNDRound a number to the nearest integer or to a specified decimal placesROUND(10.3)10
SCALEReturn the number of decimal digits in the fractional partSCALE(1.234)3
SIGNReturn the sign (positive, negative) of a numeric valueSIGN(-1)-1
SQRTReturn the square root of a numeric valueSQRT(3.0)1.732050808
TRUNCTruncate a numeric value to a whole number of  to the specified decimal placesTRUNC(12.3)12
WIDTH_BUCKETAssign values to buckets in an equi-width histogram.
RANDOMReturn a random number that ranges from 0 to 10.968435665
Previous Tutorial: PostgreSQL String Functions
Next Tutorial: PostgreSQL PHP

PostgreSQL Math Functions

  • ABS
  • CEIL
  • MOD
  • FLOOR
  • ROUND
  • TRUNC

About PostgreSQL Tutorial

PostgreSQLTutorial.com is a website dedicated to developers and database administrators who are working on PostgreSQL database management system.

We constantly publish useful PostgreSQL tutorials to keep you up-to-date with the latest PostgreSQL features and technologies. All PostgreSQL tutorials are simple, easy-to-follow and practical.

Recent PostgreSQL Tutorials

  • PostgreSQL ANY Operator
  • PostgreSQL EXISTS
  • How To Delete Duplicate Rows in PostgreSQL
  • PostgreSQL TO_CHAR Function
  • PostgreSQL TO_NUMBER Function
  • PostgreSQL TO_TIMESTAMP Function
  • PostgreSQL CEIL Function
  • PostgreSQL MOD Function
  • PostgreSQL FLOOR Function
  • PostgreSQL ABS Function

More Tutorials

  • PostgreSQL Cheat Sheet
  • PostgreSQL Administration
  • PostgreSQL PHP
  • PostgreSQL Python
  • PostgreSQL JDBC
  • PostgreSQL Resources

Site Info

  • Home
  • About Us
  • Contact Us
  • Privacy Policy

Copyright © 2017 by PostgreSQL Tutorial Website. All Rights Reserved.