Mathematical User-Defined Functions | Database Journal

Mathematical User-Defined Functions

Jan 10, 2001
2 minute read




Introduction


Mathematical UDFs


  • Factorial

  • PercentFrom

  • PercentValue

  • Degree

  • Allocation

  • Combination


  • Introduction

    I would like to write the series of articles about useful User-Defined
    Functions grouped by the following categories:


    • Date and Time User-Defined Functions

    • Mathematical User-Defined Functions

    • Metadata User-Defined Functions

    • Security User-Defined Functions

    • String User-Defined Functions

    • System User-Defined Functions

    • Text and Image User-Defined Functions


    In this article, I wrote some useful Mathematical User-Defined
    Functions.


    Mathematical UDFs

    
    These scalar User-Defined Functions perform a calculation, usually
    based on input values provided as arguments, and return a numeric
    value.
    To download Mathematical User-Defined Functions click this link:
    Download Mathematical UDFs


    Factorial

    
    Returns the factorial value of the given number.
    Syntax
    Factorial ( number )
    Arguments
    number
    Is the integer value.
    Return Types
    bigint
    The functions text:
    __ATLAS_TABLE_BLOCK__0__
    Examples
    This example returns the factorial value of the number 5:
    __ATLAS_TABLE_BLOCK__1__
    Here is the result set:
    ——————–
    120
    (1 row(s) affected)


    PercentFrom

    
    Returns the percent of the expression1 in the expression2.
    Syntax
    PercentFrom ( expression1, expression2 )
    Arguments
    expression1
    Is an expression of the exact numeric or approximate numeric
    data type category.
    expression2
    Is an expression of the exact numeric or approximate numeric
    data type category.
    Return Types
    float
    The functions text:
    __ATLAS_TABLE_BLOCK__2__
    Examples
    This example returns the percent of the 137 in the 273:
    __ATLAS_TABLE_BLOCK__3__
    Here is the result set:
    —————————————————–
    50.183150183150182
    (1 row(s) affected)
    Advertisement


    PercentValue

    
    Returns the percent’s value from the given expression for the
    given percent.
    Syntax
    PercentValue ( expression, percent )
    Arguments
    expression
    Is an expression of the exact numeric or approximate numeric
    data type category.
    percent
    Is the integer value.
    Return Types
    float
    The function’s text:
    __ATLAS_TABLE_BLOCK__4__
    Examples
    Returns the percent’s value from the number 137 for the percent 11:
    __ATLAS_TABLE_BLOCK__5__
    Here is the result set:
    —————————————————–
    15.07
    (1 row(s) affected)


    Degree

    
    Returns the degree for the given number and degree value.
    Syntax
    Degree ( number, degree )
    Arguments
    number
    Is an expression of the exact numeric or approximate numeric
    data type category.
    degree
    Is the integer value.
    Return Types
    float
    The functions text:
    __ATLAS_TABLE_BLOCK__6__
    Examples
    Returns the degree 4 for the number 3:
    __ATLAS_TABLE_BLOCK__7__
    Here is the result set:
    —————————————————–
    81.0
    (1 row(s) affected)


    Allocation

    
    Returns the allocation from the m by n.
    Syntax
    Allocation ( m, n )
    Arguments
    m
    Is the integer value.
    n
    Is the integer value.
    Return Types
    int
    The functions text:
    __ATLAS_TABLE_BLOCK__8__
    Examples
    Returns the allocation from the 5 by 3:
    __ATLAS_TABLE_BLOCK__9__
    Here is the result set:
    ———–
    60
    (1 row(s) affected)


    Combination

    
    Returns the combination from the m by n.
    Syntax
    Combination ( m, n )
    Arguments
    m
    Is the integer value.
    n
    Is the integer value.
    Return Types
    int
    The functions text:
    __ATLAS_TABLE_BLOCK__10__
    Examples
    Returns the combination from the 5 by 3:
    __ATLAS_TABLE_BLOCK__11__
    Here is the result set:
    ———–
    10
    (1 row(s) affected)



    »


    See All Articles by ColumnistAlexander Chigrik

    Alexander Chigrik

    I am the owner of MSSQLCity.Com - a site dedicated to providing useful information for IT professionals using Microsoft SQL Server. This site contains SQL Server Articles, FAQs, Scripts, Tips and Test Exams.

    Database Journal Logo

    DatabaseJournal.com publishes relevant, up-to-date and pragmatic articles on the use of database hardware and management tools and serves as a forum for professional knowledge about proprietary, open source and cloud-based databases--foundational technology for all IT systems. We publish insightful articles about new products, best practices and trends; readers help each other out on various database questions and problems. Database management systems (DBMS) and database security processes are also key areas of focus at DatabaseJournal.com.

    Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

    Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.