How should you complete the Transact-SQL statement?

DRAG DROP
Note: This question is part of a series of questions that use the same scenario. For your convenience,
the scenario is repeated in each question. Each question presents a different goal and answer choices,
but the text of the scenario is exactly the same in each question on this series.
You have a database that tracks orders and deliveries for customers in North America. System versioning is
enabled for all tables. The database contains the Sales.Customers, Application.Cities, and
Sales.CustomerCategories tables.
Details for the Sales.Customers table are shown in the following table:

Details for the Application.Cities table are shown in the following table:

Details for the Sales.CustomerCategories table are shown in the following table:

You are creating a report to measure the impact of advertising efforts that were designed to attract new
customers. The report must show the number of new customers per day for each customer category, but only if
the number of new customers is greater than five.You need to write the query to return data for the report.
How should you complete the Transact-SQL statement? To answer, drag the appropriate Transact-SQL
segments to the correct locations. Each Transact-SQL segment may be used once, more than once, or not at
all. You may need to drag the split bar between panes or scroll to view content.
Select and Place:

DRAG DROP
Note: This question is part of a series of questions that use the same scenario. For your convenience,
the scenario is repeated in each question. Each question presents a different goal and answer choices,
but the text of the scenario is exactly the same in each question on this series.
You have a database that tracks orders and deliveries for customers in North America. System versioning is
enabled for all tables. The database contains the Sales.Customers, Application.Cities, and
Sales.CustomerCategories tables.
Details for the Sales.Customers table are shown in the following table:

Details for the Application.Cities table are shown in the following table:

Details for the Sales.CustomerCategories table are shown in the following table:

You are creating a report to measure the impact of advertising efforts that were designed to attract new
customers. The report must show the number of new customers per day for each customer category, but only if
the number of new customers is greater than five.You need to write the query to return data for the report.
How should you complete the Transact-SQL statement? To answer, drag the appropriate Transact-SQL
segments to the correct locations. Each Transact-SQL segment may be used once, more than once, or not at
all. You may need to drag the split bar between panes or scroll to view content.
Select and Place:

Answer:

Explanation:
Box 1: IN (
The IN clause determines whether a specified value matches any value in a subquery or a list.
Syntax: test_expression [ NOT ] IN ( subquery | expression [ ,…n ] )
Where subquery is a subquery that has a result set of one column. This column must have the same data type
as test_expression.
Box 2: WHERE
Box 3: AND [IsOnCreditHold] = 0
Box 4: )
https://msdn.microsoft.com/en-us/library/ms177682.aspx



Leave a Reply 9

Your email address will not be published. Required fields are marked *


Teuta

Teuta

In the answer, I think “Where” should replace with “Having” as we can’t use aggregate functions in the where clause.

LuckyChap

LuckyChap

I agree with Teuta, ‘Having’ should be used instead of ‘WHERE’

LW

LW

I think the bottom two should be switched, since IsOnCreditHold is an attribute of the Customers table which is the outer query.
There is also a ( missing after the IN.

scotrid

scotrid

Select CustomerID
from customers2
where postalCityID in

(select citiyID
from Cities
where LatestRecordedPopulation > 10000)
and IsoncreditHold = 0

Peter

Peter

This is also my opinion.

Peter

Peter

Agree with both.

If it stays like in the given answer it will not work as IsOnCreditHold belongs to customers not to cities, which is the table of the subselect.

EY Audtior

EY Audtior

ok correct.