PrepAway - Latest Free Exam Questions & Answers

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:

PrepAway - Latest Free Exam Questions & Answers

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

5 Comments on “How should you complete the Transact-SQL statement?

  1. eder says:

    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 statemen
    *RECUERDEN QUE PIDE UN REPORTE POR DIA Y POR CADA CATEGORIA DE CLIENTE

    SELECT COUNT( e.custid),C.CustomerCategoryName ,DATEPART(DAY,e.AccountOpenedDate )
    FROM Sales.Customers AS e
    INNER JOIN Sales.CustomerCategories as c
    ON E.customerCategoryId=C.customerCategoryId
    GROUP BY C.CustomerCategoryName,DATEPART(DAY,e.AccountOpenedDate )
    HAVING COUNT( e.custid)>5




    0



    5
  2. eqfwcev123 says:

    Hi, I have just started to learn sql server.
    I have a question in the SELECT statement. similar to eder’s opinion,
    I think the date should be wirtten in DATEPART(Day, e.AccountOpendDate)
    since the question required us to show number of customers <>
    so i thought DATEPART would be a more suitable one.
    Could anyone please explain why we have to use CAST instead of DATEPART?
    Thank you




    0



    0

Leave a Reply