How can I write a query to exclude rows in a table?

How do I  exclude those rows where crew job for a particular char_trip, such as 10003  is both pilot and copilot from the table data below? I was trying to do something like the attached code snippet.

CHAR_TRIP      EMP_NUM      CREW_JOB
10001      104      Pilot
10002      101      Pilot
10003      105      Pilot
10003      109      Copilot
10004      106      Pilot
10005      101      Pilot
10006      109      Pilot
10007      104      Pilot
10007      105      Copilot
10008      106      Pilot
10009      105      Pilot
10010      108      Pilot
10011      101      Pilot
10011      104      Copilot
10012      101      Pilot
10013      105      Pilot
10014      106      Pilot
10015      101      Copilot
10015      104      Pilot
10016      105      Copilot
10016      109      Pilot
10017      101      Pilot
10018      104      Copilot
10018      105      Pilot
SELECT DISTINCT (CHARTER.CHAR_TRIP) AS [CHAR_TRIP], REPLACE(CONVERT(VARCHAR(9),CHAR_DATE,6),' ', '-'), 
CHARTER.AC_NUMBER, MODEL.MOD_NAME, EMPLOYEE.EMP_LNAME, CREW.CREW_JOB
FROM MODEL INNER JOIN AIRCRAFT ON MODEL.MOD_CODE = AIRCRAFT.MOD_CODE 
INNER JOIN CHARTER ON AIRCRAFT.AC_NUMBER = CHARTER.AC_NUMBER 
INNER JOIN CREW ON CHARTER.CHAR_TRIP = CREW.CHAR_TRIP
INNER JOIN EMPLOYEE ON CREW.EMP_NUM = EMPLOYEE.EMP_NUM
WHERE (((CREW.CREW_JOB)<>'CoPilot'))
MINUS
SELECT COUNT(DISTINCT (CHAR_TRIP)) AS [Number of Trips],CHAR_TRIP
FROM CREW
GROUP BY CHAR_TRIP
HAVING Count(CHAR_TRIP) >1;

Open in new window

Barbara69Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fanopoeCommented:
select *
from YourTable
where CHAR_TRIP not in(select CHAR_TRIP
from your table
where CREW_JOB = 'Pilot' and CHAR_TRIP in(select CHAR_TRIP
from your table
where CREW_JOB = 'Copilot')



hth

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Barbara69Author Commented:
Thank you, so very much for your assistance.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.