Wednesday, April 19, 2017

FLOOR() in SQL Server


SQL FLOOR() function is used to return the nearest least integer value either positive or negative. Returns the largest integer less than or equal to value specified in numerical expression. NULL values are not rounded off. FLOOR() does not work on non-numeric columns such as text.


Syntax:

     
            SELECT FLOOR (numeric_expression)


numeric_expression is the numeric value of which floor value is to be calculated.


Example 1:
FLOOR() on numeric column.

SELECT * FROM TempEmployeePayHistory



SELECT Rate, FLOOR(Rate) FROM TempEmployeePayHistory



Example 2:
FLOOR() on column with NULL values.

          SELECT * FROM TempEmployeePayHistory
  


SELECT Rate, FLOOR(Rate) FROM TempEmployeePayHistory
  


Example 3:
FLOOR() on text column.

          SELECT * FROM DatabaseLog
  


          SELECT [Event], FLOOR([Event]) FROM DatabaseLog



Share This
Previous Post
Next Post

TekGrabs, established in 2017, is in the business of sharing Information. It provides news, articles and photos about the different technologies, inventions in different domains. Provides information on programming and databases.

0 comments: