Home > SQL Server, T-SQL > SQL SERVER – FLOOR() – Math Functions @SQLSERVER

SQL SERVER – FLOOR() – Math Functions @SQLSERVER


Just to remember FLOOR function is used to convert the decimal number to the lowest whole number.

FLOOR() function returns the lowest or equal value of a given numeric argument. If the argument (numeric expression) is zero then the output will be zero. The return value data type is the same type as numeric_expression.

Syntax

FLOOR(Numeric_Expression)

Examples

select Floor(0.5)
Output: 0

select Floor(3.0)
Output: 3

select Floor(0)
Output: 0

select Floor(3.5)
Output: 3

This Code block prints the FLOOR value of a series of decimal number:

declare @floatvalue as float = 8.0
declare @i as tinyint = 1
while  @i <= 10
begin
set @floatvalue = @floatvalue + 0.1
Print ‘FLOOR(‘+cast(@floatvalue as varchar(3))+’)= ‘
Print FLOOR(@floatvalue)

set @i = @i +1
end

Output:

Execute this code in SSMS and get the output in your machine. Happy programming!!!

Advertisements
  1. No comments yet.
  1. January 1, 2013 at 11:31 pm

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

%d bloggers like this: