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!

HI Guys i have a question please give the solution

Discussion in 'SQL PL/SQL' started by mahesh32145, Jun 18, 2015.

  1. mahesh32145

    mahesh32145 Newly Initiated

    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    30
    i have two tables a and b in table a having tow columns id and hiredate and table b also having same columns so,
    table a:
    id hiredate
    1 23-may-2015
    2 21-may-2014
    3 15-jun-2012

    table b :
    id hiredate
    1 21-apr-2013
    2 29-jun-2014
    3 14-aug-2013

    but my output would be

    id hiredate
    1 21-apr-2013
    2 21-may-2014
    3 14-aug-2013

    so, please give a solution for this.

    Thanks
    Mahesh
     
  2. jagadekara

    jagadekara Forum Guru

    Messages:
    1,126
    Likes Received:
    145
    Trophy Points:
    1,805
    Location:
    Pulivendula
    Hi,

    Why you need like this?

    On what basis we need to control the data like this?
     
  3. ocprep

    ocprep Forum Advisor

    Messages:
    277
    Likes Received:
    76
    Trophy Points:
    410
    Location:
    Orlando, Florida
    Beyond why, but what is the logic being used? I don't see any pattern in displaying row 1 of table B, then row 2 of table a, then row 3 of table b.
     
  4. mahesh32145

    mahesh32145 Newly Initiated

    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    30
    interviewer asked that question

    if table1 id = table2 id then display the corresponding smallest day column from the table1 or table2.

    please tell me how it will be.



    thanks,
    mahesh
     
  5. ocprep

    ocprep Forum Advisor

    Messages:
    277
    Likes Received:
    76
    Trophy Points:
    410
    Location:
    Orlando, Florida
    Something like the following should work:

    Code (Text):
    SELECT A.id, LEAST(A.hiredate, B.hiredate) AS LEAST_HIREDATE
    FROM   tableA A
           INNER JOIN tableb B
           ON A.id = B.id;
     
  6. mahesh32145

    mahesh32145 Newly Initiated

    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    30
    HI Matthew,
    yes it is working and thanks for your information.

    Thanks,
    Mahesh