PrepAway - Latest Free Exam Questions & Answers

Which Transact- SQL query or queries should you use?

You administer a Microsoft SQL Server database that supports a shopping application.
You need to retrieve a list of customers who live in territories that do not have a sales person.
Which Transact- SQL query or queries should you use? (Each correct answer presents a complete
solution. Choose all that apply.)

PrepAway - Latest Free Exam Questions & Answers

A.
SELECT CustomerID FROM Customer
WHERE TerritoryID <> SOME(SELECT TerritoryID FROM Salesperson)

B.
SELECT CustomerID FROM Customer
WHERE TerritoryID <> ALL(SELECT TerritoryID FROM Salesperson)

C.
SELECT CustomerID FROM Customer
WHERE TerritoryID <> ANY(SELECT TerritoryID FROM Salesperson)

D.
SELECT CustomerID FROM Customer
WHERE TerritoryID NOT IN(SELECT TerritoryID FROM Salesperson)

11 Comments on “Which Transact- SQL query or queries should you use?

    1. Juan says:

      Agree with Petrovich. Take a look at his reference link. This is what I understood.

      “The ANY operator means not = a, or not = b, or not = c. NOT IN means not = a, and not = b, and not = c. ALL means the same as NOT IN. SOME is an ISO standard equivalent for ANY.”

      which means:
      territoryID Any(list of territoryID) will return true if one territoryID in the list equals territoryID
      while territoryID All(list of territoryID) will only return true if all territoryID on the list = territoryID which in this case will be false since every territory has their own territoryID

      Just keep in mind that:
      “The =ANY operator is equivalent to IN.”




      0



      0
  1. Mel says:

    If ALL is equivalent to NOT IN then B and D are the same.

    The ANY operator, however, differs from NOT IN: ANY means not = a, or not = b, or not = c. NOT IN means not = a, and not = b, and not = c. ALL means the same as NOT IN.

    ANY is not the same as NOT IN.




    0



    0
  2. Tortellini says:

    B,D

    The ANY operator, however, differs from NOT IN: ANY means not = a, or not = b, or not = c. NOT IN means not = a, and not = b, and not = c.

    ALL means the same as NOT IN.




    0



    0

Leave a Reply