How to Round Up in SQL

  • google plus

In Brief...

In SQL, you round up to the nearest integer using the CEIL or CEILING function, depending on whether you're using SQL Server, Oracle, MySQL or PostgreSQL.

Take our Introduction to SQL Training course for free.

See the Course Outline and Register

Instructions

Rounding up in SQL Server

In SQL Server, you round up with the CEILING() function.

SELECT CEILING(5.2)
Output:
6

Rounding Up in Oracle, MySQL, and PostgreSQL

In Oracle, MySQL, and PostgreSQL, you can use either the CEIL() or CEILING() function to round up.

SELECT CEIL(5.2)
SELECT CEILING(5.2)
Output:
6

Webucator provides instructor-led training to students throughout the US and Canada. We have trained over 90,000 students from over 16,000 organizations on technologies such as Microsoft ASP.NET, Microsoft Office, XML, Windows, Java, Adobe, HTML5, JavaScript, Angular, and much more. Check out our complete course catalog.

Categories

Courses

Author: Nat Dunn

Nat Dunn founded Webucator in 2003 to combine his passion for technical training with his business expertise and to help companies benefit from both. His previous experience was in sales, business and technical training, and management. Nat has an MBA from Harvard Business School and a BA in International Relations from Pomona College.

Discuss