Results 1 to 4 of 4

Thread: Need SQL Query

  1. #1
    Join Date
    Aug 2002
    Posts
    24

    Thumbs up Unanswered: Need SQL Query

    KEY CORP_NUMBER COMPANY

    --- ---------- -----------

    X 802548374 ACC

    X 802548374 ACC

    - 802548374 ACC

    - 802548374 ACC

    - 802548374 ACC

    - 802548374 ACC

    X 802660871 CASHCOM

    - 802660871 CASHCOM

    - 802660871 CASHCOM

    - 802994567 NORTHSTART

    - 802994567 NORTHSTART

    X 802994567 NORTHSTART

    X 111111111 HONDA MOTOR

    - 111111111 HONDA MOTOR

    - 111111111 HONDA MOTOR

    X 222222222 TOYOTA

    - 222222222 TOYOTA

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    X 444444444 AUDI

    - 555555555 CHRYSLER

    As per the above Sample data, i need a query for retrieving the
    entire COMPANY with missing key values(as 'X'). Can any one help me?

    Expected output:

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 555555555 CHRYSLER

    Thanks
    Laca

  2. #2
    Join Date
    Jan 2002
    Location
    USA
    Posts
    53

    Re: Need SQL Query

    Try this one:

    Select CORP_NUMBER COMPANY from table where comp_number not in (select comp_number from table where key = X)


    ljrong


    Originally posted by dbtwodba
    KEY CORP_NUMBER COMPANY

    --- ---------- -----------

    X 802548374 ACC

    X 802548374 ACC

    - 802548374 ACC

    - 802548374 ACC

    - 802548374 ACC

    - 802548374 ACC

    X 802660871 CASHCOM

    - 802660871 CASHCOM

    - 802660871 CASHCOM

    - 802994567 NORTHSTART

    - 802994567 NORTHSTART

    X 802994567 NORTHSTART

    X 111111111 HONDA MOTOR

    - 111111111 HONDA MOTOR

    - 111111111 HONDA MOTOR

    X 222222222 TOYOTA

    - 222222222 TOYOTA

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    X 444444444 AUDI

    - 555555555 CHRYSLER

    As per the above Sample data, i need a query for retrieving the
    entire COMPANY with missing key values(as 'X'). Can any one help me?

    Expected output:

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 555555555 CHRYSLER

    Thanks
    Laca

  3. #3
    Join Date
    Aug 2002
    Posts
    24

    Re: Need SQL Query

    What about "Chrysler" record? I am not getting that in the result..!!!
    Thanks
    Laca



    Originally posted by dbtwodba


    KEY CORP_NUMBER COMPANY

    --- ---------- -----------

    X 802548374 ACC

    X 802548374 ACC

    - 802548374 ACC

    - 802548374 ACC

    - 802548374 ACC

    - 802548374 ACC

    X 802660871 CASHCOM

    - 802660871 CASHCOM

    - 802660871 CASHCOM

    - 802994567 NORTHSTART

    - 802994567 NORTHSTART

    X 802994567 NORTHSTART

    X 111111111 HONDA MOTOR

    - 111111111 HONDA MOTOR

    - 111111111 HONDA MOTOR

    X 222222222 TOYOTA

    - 222222222 TOYOTA

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    X 444444444 AUDI

    - 555555555 CHRYSLER

    As per the above Sample data, i need a query for retrieving the
    entire COMPANY with missing key values(as 'X'). Can any one help me?

    Expected output:

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 555555555 CHRYSLER

    Thanks
    Laca

  4. #4
    Join Date
    Aug 2002
    Posts
    24

    Re: Need SQL Query

    oOOOPS......I GOT IT. THANKU VERY MUCH.





    Originally posted by dbtwodba
    KEY CORP_NUMBER COMPANY

    --- ---------- -----------

    X 802548374 ACC

    X 802548374 ACC

    - 802548374 ACC

    - 802548374 ACC

    - 802548374 ACC

    - 802548374 ACC

    X 802660871 CASHCOM

    - 802660871 CASHCOM

    - 802660871 CASHCOM

    - 802994567 NORTHSTART

    - 802994567 NORTHSTART

    X 802994567 NORTHSTART

    X 111111111 HONDA MOTOR

    - 111111111 HONDA MOTOR

    - 111111111 HONDA MOTOR

    X 222222222 TOYOTA

    - 222222222 TOYOTA

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    X 444444444 AUDI

    - 555555555 CHRYSLER

    As per the above Sample data, i need a query for retrieving the
    entire COMPANY with missing key values(as 'X'). Can any one help me?

    Expected output:

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 333333333 NISSAN AUTO

    - 555555555 CHRYSLER

    Thanks
    Laca

Posting Permissions

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