Results 1 to 5 of 5

Thread: SQL Query Help

  1. #1
    Join Date
    Jun 2013
    Posts
    3

    Unanswered: SQL Query Help

    I have to qurery to get the distict value of coulmn 2 where coumn3 has value X. For example B2 has a value 'Q' in column2 then it should not be selected.All B3 has value X then it should be selected.
    Any help will be appriciated.


    Coloumn1 Coloumn2 Coloumn3
    1 B1 X
    2 B1 X
    3 B2 Q
    4 B2 X
    5 B2 X
    6 B3 X
    7 B3 X
    8 B3 X
    9 B4 Q
    10 B4 Q
    11 B5 X
    12 B6 X
    13 B6 X

    Result
    Coloumn2
    B1
    B3
    B5
    B6

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Select distinct column2 from table1 where column3 = 'x';
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Jun 2013
    Posts
    3
    @anacedent:
    This will get back B2 which is not that I want....B2 has a value Q associated with it.I want to select distinct value of coulmn 2 that has only value 'X' and none of the the distict value of B2 has 'Q' in coulumn 3.I hope I am able to explain

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Select column2 from table1 where column3 = 'x'
    minus
    select column2 from table1 where column3 != 'X';
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  5. #5
    Join Date
    Jun 2013
    Posts
    3

    Thumbs up

    Thanks A lot!!!!! That solved my problem...you came as

    Thanks
    Deepi

Tags for this Thread

Posting Permissions

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