CORRECT TEXT

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

CORRECT TEXT

You have a SQL Server database that contains all of the sales data for your company.

You need to create a query that returns the customers who represent the top five percent of the total actual sales.

Part of the correct Transact-SQL has been provided in the answer area below. Enter the code in the answer area that resolves the problem and meets the stated goals or requirements. You can add code within the code that has been provided as well as below it.

Use the Check Syntax button to verify your work. Any syntax or spelling errors will be reported by

line and character position.

Answer: Please review the explanation part for this answer

Explanation:

1 SELECT CustomerID, N

2 ,Top5= TOP (0,95) PERCENT Sales (ORDER BY N) OVER (PARTITION BY Sales)

3 FROM Customers;

Add TOP and PERCENT Sales on line 2.

Syntax:

TOP (expression) [PERCENT]

[ WITH TIES ]

]

expression

Is the numeric expression that specifies the number of rows to be returned. expression is implicitly converted to a float value if PERCENT is specified; otherwise, it is converted to bigint.

PERCENT

Indicates that the query returns only the first expression percent of rows from the result set. Fractional values are rounded up to the next integer value.

References: https://docs.microsoft.com/en-us/sql/t-sql/queries/top-transact-sql?view=sql-server­2017

Leave a Reply

Your email address will not be published.