Solved

SQL  Query question

Posted on 2013-01-13
7
290 Views
Last Modified: 2013-01-15
I need sql queries  for the questions below: I included the queries that I am using but gives me one saleperson only. I know that "two orders do not have items."    

Th tables are in the attached file.

If I need to use full outer join query then how can I implement that ?   Thank you

Which sales people have NOT sold anything?    Subquery version

SELECT s.Ename
FROM SALESPERSONS s
WHERE s.EmpID NOT IN(
SELECT o.EmpID
FROM ORDERS o
   , SALESPERSONS s
WHERE o.EmpID = s.EmpID);
GO

Which sales people have NOT sold anything? JOIN version (explicit/named JOIN)

SELECT s.Ename
FROM SALESPERSONS s
FULL OUTER  JOIN  ORDERS o ON o.EmpID = s.EmpID
WHERE o.EmpID IS NULL;
sqltables.doc
0
Comment
Question by:ocdc
[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
  • 3
7 Comments
 
LVL 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 500 total points
ID: 38772936
SELECT s.Ename 
FROM SALESPERSONS s
WHERE NOT EXISTS(
    SELECT 1
    FROM ORDER o WHERE o.EmpID = s.EmpID)

Open in new window

0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 38772937
Another:

SELECT s.Ename 
FROM SALESPERSONS s LEFT JOIN
    ORDER o WHERE o.EmpID = s.EmpID
WHERE o.EmpID IS NULL

Open in new window

0
 

Author Comment

by:ocdc
ID: 38773057
Which Customer  placed the most orders?
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

Author Comment

by:ocdc
ID: 38773061
more info.  for    Which Customer  placed the most orders?  I need to show:

CUSTOMERS.custid, CUSTOMERS.cname, and a count
0
 

Author Comment

by:ocdc
ID: 38774177
I've requested that this question be deleted for the following reason:

no need
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 38774178
I object to deleting this question.  I offered two different ways to resolve the original question before the Asker (1) completely changed the question and then (2) decided that s/he no longer wanted to proceed.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 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