How should you complete the stored procedure?

Posted by: Pdfprep Category: 70-461 Tags: , ,

DRAG DROP

You administer a SQL Server database that tracks sales that are made by sales persons.

The database contains a table that is defined by the following Transact-SQL statements:

You have the following requirements:

– accept a datetime value for the query month

– return a list of salespeople IDs who have sales in the query month or before the query month

– compare sales with sales quota for salespeople who have a sales quota

– display year-to-date sales for salespeople that do not have a sales quota

How should you complete the stored procedure? 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.

Answer:

Explanation:

Box 1: IIF ..

The IIF logical function returns one of two values, depending on whether the Boolean expression evaluates to true or false in SQL Server.

Syntax: IIF ( boolean_expression, true_value, false_value )

Box 2: [LastSzale] < EOMONTH(@queryMonth)

The EOMONTH function returns the last day of the month containing a specified date, with an optional offset.

References: https://docs.microsoft.com/en-us/sql/t-sql/functions/logical-functions-iif-transact-sql?view=sql­server-2017 https://docs.microsoft.com/en-us/sql/t-sql/functions/eomonth-transact-sql?view=sql-server-2017

Leave a Reply

Your email address will not be published.