exam questions

Exam 70-761 All Questions

View all questions & answers for the 70-761 exam

Exam 70-761 topic 1 question 72 discussion

Actual exam question from Microsoft's 70-761
Question #: 72
Topic #: 1
[All 70-761 Questions]

You have a database that contains the following tables:

You need to write a query that returns a list of all customers who have not placed orders.
Which Transact-SQL statement should you run?

  • A. SELECT c.custid FROM Sales.Customers c INNER JOIN Sales.Order o ON c.custid = o.custid
  • B. SELECT custid FROM Sales.Customers INTERSECT SELECT custid FROM Sales.Orders
  • C. SELECT c.custid FROM Sales.Customers c LEFT OUTER Sales.Order o ON c.custid = o.custid
  • D. SELECT c.custid FROM Sales.Customers c LEFT OUTER JOIN Sales.Order o ON c.custid = o.custid WHERE orderid IS NULL
  • E. SELECT custid FROM Sales.Customers UNION ALL SELECT custid FROM Sales.Orders
  • F. SELECT custid FROM Sales.Customers UNION SELECT custid FROM Sales.Orders
  • G. SELECT c.custid FROM Sales.Customers c RIGHT OUTER JOIN Sales.Orders o ON c.custid = o.custid
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️
Inner joins return rows only when there is at least one row from both tables that matches the join condition. Inner joins eliminate the rows that do not match with a row from the other table. Outer joins, however, return all rows from at least one of the tables or views mentioned in the FROM clause, as long as those rows meet any WHERE or HAVING search conditions. All rows are retrieved from the left table referenced with a left outer join, and all rows from the right table referenced in a right outer join. All rows from both tables are returned in a full outer join.
References:
https://technet.microsoft.com/en-us/library/ms187518(v=sql.105).aspx

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
stm22
Highly Voted 4 years, 11 months ago
when question contains " HAVE NOT ", think EXCEPT or IS NULL. when question contains " HAVE ", think INTERSECT or IS NOT NULL
upvoted 6 times
okus
4 years, 11 months ago
Thanks :)
upvoted 1 times
...
...
kiri2020
Most Recent 4 years, 8 months ago
D is correct, although I wouldn't write it that way, I would write: select CustID from Customers as C where not exists ( select 1 from Orders as O where O.CustID = C.CustID)
upvoted 2 times
...
OrleD
4 years, 10 months ago
G looks good too.
upvoted 1 times
OrleD
4 years, 10 months ago
My bad, G returns all orders and customers that have orders. Sry.
upvoted 1 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...