The SQL CEILING function returns the smallest integer value greater than or
Use SQL mathematical functions to perform business and engineering calculations. I’ll cover the commonly used functions, as you won’t many of them in day-to-day operations.
If you’re new to SQL and want to get to know more about SQL Function right now, then read Introduction to SQL Server Built-In Functions.
All the examples for this lesson are based on Microsoft SQL Server Management Studio and the AdventureWorks2012 database. Get a head start learning SQL. Download my free guide Getting Started Using SQL Server.
Introduction to SQL Server’s Mathematical Functions
There are many SQL mathematical functions for you to use. I categorize them as:
- Scientific and Trig Functions
- Rounding Functions
- Random Numbers
The SQL MSDN page is a great reference. If you want to dig deep into functions, it is your go to place.
Rather than reiterate that material, let’s focus on the functions commonly used in business.
I put together a table of functions. It is color coded. The color code corresponds to the likely hood you’ll used a particular function within business: Green are most likely used, and red less so.
OK – SpaceX will use some of the red ones, but hey, they’re rocket scientists!
This isn’t a strict scale, and all functions are awesome (I’m an engineer and love math), but I wanted a way to help you winnow down the field to those most relevant.
Here is my attempt:
The SQL FLOOR function returns the largest integer that is smaller or equal to the input expression. Description The FLOOR function helps
The SQL RAND function generates a random number between the range of 0 and 1. The number can be greater than equal
The SQL ROUND function rounds a numeric value up to a specified number of decimal places or precision. Description The SQL ROUND