GREATER function in MS SQL

Posted on 2006-03-27
Last Modified: 2008-02-26

Is there a function in MS SQL that returns the greater value of 2 expressions, like GREATER(exp1,exp2) in Sybase?

Question by:BlueAlien
    LVL 44

    Expert Comment

    Hi BlueAlien,

    No but you can use the case construct:

    Select Case When ValueA>ValueB Then ValueA Else ValueB End As GreatestValue

    Tim Cottee
    LVL 44

    Accepted Solution

    You can also create a User Defined Function (UDF) in SQL Server which will carry out the same operation, and you could even name that UDF GREATER.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
    Read about achieving the basic levels of HRIS security in the workplace.
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now