Follow us: Connect on YouTube Connect on YouTube Connect on YouTube

Pages

Friday, 1 April 2016

SQL-Greatest


This will give the greatest string.

     Syntax: greatest (strng1, string2, string3 … stringn)     

     Ex:
           SQL> select greatest('a', 'b', 'c'), greatest('satish','srinu','saketh') from dual;

GREAT GREAT
-------  -------
    c         srinu

If all the parameters are nulls then it will display nothing.
 If any of the parameters is null it will display nothing.



You May Like                                             
                            SQL Abs
                            SQL Sign
                            SQL Sqrt
                            SQL Mod
                            SQL NVL
                            SQL NVL2
                            SQL Power
                            SQL Exp
                            SQL Ln
                            SQL Log
                            SQL CEIL
                            SQL Floor
                            SQL Round
                            SQL Trunc
                            SQL Bitand                          
                            SQL Least
                            SQL Coalesce
 
Share this article :

1 comments:

  1. Hi dayakar,

    Smokin hot stuff! You’ve trimmed my dim. I feel as bright and fresh as your prolific website and blogs!


    CREATE table irt_test
    (
    mob numeric(20),
    acct varchar(20),
    mmid varchar(20),
    err_msg varchar(20),
    )

    insert into irt_test(MOB,ACCT,MMID) values(999,123,456)
    insert into irt_test (MOB,ACCT,MMID)values(999,123,456)

    insert into irt_test (MOB,ACCT,MMID) values(102,856,987)
    insert into irt_test (MOB,ACCT,MMID) values(102,625,987)

    insert into irt_test (MOB,ACCT,MMID) values(632,152,954)
    insert into irt_test (MOB,ACCT,MMID) values(632,962,357)



    If mob,acc and mmid
    is repeated then i want to update as duplicate mob,acct,mmid
    if for same mob and same repeated then i want to update as Duplicate MMID FOR same MOB


    select * from irt_test

    Expected result

    mob acct mmid err_msg
    999 123 456 Duplicate record mob,acct and MMID
    999 123 456 Duplicate record mob,acct and MMID

    102 856 987 Duplicate MMID for same MOB
    102 625 987 Duplicate MMID for same MOB
    632 152 954
    632 962 357

    Thanks a lot. This was a perfect step-by-step guide. Don’t think it could have been done better.

    Many Thanks,
    Irene Hynes

    ReplyDelete