Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Question about simple SQL query

Posted on 2008-06-16
3
Medium Priority
?
176 Views
Last Modified: 2010-04-21
I am trying to only get records back when the inspector (lbal_inspectedby) is not the same as any of the inspectors in the query.  So,

SELECT * FROM LBAppraisalLocation WHERE lbal_appraisalid=xxxx AND lbal_inspectedby IS NOT THE SAME AS ANY OF THE OTHERS?????

So if the table looked like this
ID    lbal_appraisalid     lbal_inspectedby
1     4000                     2
2     4000                     14
3     4000                     2

then my query should only return
ID    lbal_appraisalid     lbal_inspectedby
1     4000                     2
2     4000                     14

How can I do this?
0
Comment
Question by:saturation
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 21797122
not knowhing the exact column names...
select id, lbal_appraisalid, lbal_inspectedby 
  from LBAppraisalLocation l
 where lbal_appraisalid = xxxx
   and not exists ( select null from LBAppraisalLocation i 
                     where i.lbal_appraisalid = l.lbal_appraisalid
                       and i.lbal_inspectedby = l.lbal_inspectedby 
                       and i.id < l.id 
                )

Open in new window

0
 
LVL 7

Expert Comment

by:garethh86
ID: 21797181
SELECT DISTINCT(lbal_inspectedby), *  WHERE Lbal_appraisalid=@appraisalid FROM LBAppraisalLocation

Hope this helps!
0
 

Author Closing Comment

by:saturation
ID: 31467743
Great!  Worked like a charm.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question