1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

hellp me in function plzzzz its urgent

Discussion in 'SQL PL/SQL' started by saadahmed, Sep 9, 2011.

  1. saadahmed

    saadahmed Active Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    55
    Location:
    karachi
    hiy and hello to alll dears
    i have report to genrate my user reuiment is that if price rate date 6 month old then return('O')
    if date 18 months old return ('N')
    plz tell me what can i do plzzzz help dear freind
     
  2. Sadik

    Sadik Community Moderator Forum Guru

    Messages:
    1,906
    Likes Received:
    252
    Trophy Points:
    1,455
    have u written any code for it? What's your table structure?
     
  3. saadahmed

    saadahmed Active Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    55
    Location:
    karachi
    no sir i havent return any thing coz i m confuse
    struture r u asking abt column or other else
    plz help me sir
     
  4. saadahmed

    saadahmed Active Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    55
    Location:
    karachi
    i want some instructions abt this
    yani any logic etc plzzzzzzzzzzzzzzzzz
     
  5. rajavu

    rajavu Forum Guru

    Messages:
    815
    Likes Received:
    52
    Trophy Points:
    610
    Location:
    @ Bangalore , India
    Might be a late reply.

    Code (SQL):

    SQL> WITH rec AS (
    SELECT TRUNC(sysdate)-100 x FROM dual UNION
      2    3  SELECT add_months (TRUNC(sysdate),-7) FROM dual UNION
      4  SELECT add_months (TRUNC(sysdate),-20) FROM dual
      5  )
      6  SELECT x ,  CASE WHEN months_between(TRUNC(sysdate),x)  BETWEEN 0 AND 6 THEN 'X'
      7                   WHEN months_between(TRUNC(sysdate),x)  BETWEEN 7 AND 18 THEN 'O'
      8                   WHEN months_between(TRUNC(sysdate),x) > 19   THEN 'N'
      9              END  fla
     10  FROM rec;

    X         F
    --------- -
    19-FEB-10 N
    19-MAR-11 O
    11-JUL-11 X

    SQL>