Solved

Question about simple SQL query

Posted on 2008-06-16
3
166 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
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Custom headers 9 34
Access left join query 5 31
SQL Select Query help 3 32
combine an MS SQL string in Idera DM 9 32
Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now