Query
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Query

  1. #1
    Join Date
    Jan 2002
    Posts
    16

    Query

    Hi Every one...

    Please let me know how to write this query......

    Lets say I have the following data in a table which has 3 columns..

    X Y Ind
    1 1 Y
    2 1 N
    3 1 Y
    4 1 Y
    5 2 Y
    6 3 Y


    I want to write a query to retrieve all the rows with ind = 'Y' and also the rows which do not have y values duplicated...Inthis case my query should retrieve...
    5 2 Y
    6 3 Y

    X column is primary key.....How do I eliminate duplicates in Y column...

    Appreciate your help...



    Thanks....
    san

  2. #2
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Code:
    select *
    from my_table t1
    where t1.ind = 'Y'
    and not exists (select null
                    from my_table t2
                    where t2.y = t1.y
                    and t1.rowid != t2.rowid);
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  3. #3
    Join Date
    Jan 2002
    Posts
    16
    Thank you!
    san

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width