StudentCodingHUB

Use programming to create innovative things.
  • new post

    Monday, 27 April 2015

    GREATEST() and LEAST() Functions in mysql

    GREATEST() and LEAST() Functions

    The values specified can be numeric, string, or date/time values, that means GREATEST() and LEAST() takes numeric, string, or date/time values as argument.

    SELECT GREATEST(4, 83, 0, 9, -3);

    SELECT BookID, BookTitle, PublisherID
    FROM Books
    WHERE PublisherID=GREATEST(@id1, @id2, @id3, @id4, @id5)
    ORDER BY BookTitle;


    Here PublisherID  is the greatest value among given values.


    SELECT LEAST(4, 83, 0, 9, -3);

    SELECT BookID, BookTitle, PublisherID
    FROM Books
    WHERE PublisherID=LEAST(@id1, @id2, @id3, @id4, @id5)
    ORDER BY BookTitle;

    Here PublisherID  is the least value among given values.

    No comments:

    Post a Comment