The procedure returns the maximum quantity of a product that was sold in a single order before a specific date and that has a product ID of 1. Which statements should you use to identify the maximum quantity of the product that was sold in a single orde before the year 2010?

You have created the following stored procedure:

CREATE PROCEDURE MaxSales @p1 datetime, @p2 int OUTPUT AS SELECT @p2=MAX(Quantity) FROM Sales WHERE Date < @p1 AND Product ID = 1.

The procedure returns the maximum quantity of a product that was sold in a single order before a specific date and that has a product ID of 1. Which statements should you use to identify the maximum quantity of the product that was sold in a single orde before the year 2010?


Answer: – DECLARE @q int EXEC MaxSales ‘Jan 01, 2010’, @q = @p2 PRINT @q OUTPUT PRINT @q

(SQL Server changes the date at midnight. Since you want the results prior to 2010 (and not including the first day of the new year) you must set the date for December 31.)