Solved

SQL  Query question

Posted on 2013-01-13
7
291 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

623 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