decode and least function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • blurryhaddad
    New Member
    • Aug 2007
    • 2

    decode and least function

    hi all..
    i dont understand this sql statement(decod e and least)
    please help me..

    sum(decode(f.co de_category,'3' , nvl(decode(d.fl ag_result,null, decode(least(b. date,:p_startin gdate+1)b.date, 1),0),1),0))


    please convert this to if and else statement...so that i can understand...th ank you..
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    As you have posted a qustion it articles section it is moved to Oralce forum.

    MODERATOR.

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      Originally posted by blurryhaddad
      hi all..
      i dont understand this sql statement(decod e and least)
      please help me..

      sum(decode(f.co de_category,'3' , nvl(decode(d.fl ag_result,null, decode(least(b. date,:p_startin gdate+1)b.date, 1),0),1),0))


      please convert this to if and else statement...so that i can understand...th ank you..
      decode returns a particular value is the condition is satisfied or the 2nd value if the second cond is satisfied ,if no condition satisfies the it returns null,it else statment is not specified.

      least ---returns the least value in the list , in your case the least date out of two daes.

      I can convert it to IF ...ELSE


      but the problem is it is not possible to execute IF ....ELSE directly in sql statments.

      if u stilll have doubts please dopost back.

      Comment

      • nramrits
        New Member
        • Sep 2007
        • 18

        #4
        CHECK THIS IF ..ELSE FORMATE
        SUM(
        IF f.code_category =3
        THEN
        IF d.flag_result= null
        THEN
        IF b.date <= p_startlngdate+ 1 THEN
        RETURN(b_date)
        END IF;
        ELSE-- NOT NULL THEN
        RETURN 1;
        END IF;
        ELSE
        RETURN (0)
        END IF

        Comment

        Working...