CORRECT TEXT
You have a database named Sales that contains the tables as shown in the exhibit. (Click the Exhibit button.)
You need to create a query that returns a list of products from Sales.ProductCatalog. The solution must meet the following requirements:
Return rows ordered by descending values in the UnitPrice column.
Use the Rank function to calculate the results based on the UnitPrice column.
Return the ranking of rows in a column that uses the alias PriceRank.
Use two-part names to reference tables.
Display the columns in the order that they are defined in the table. The PriceRank column must appear last.
Part of the correct T-SQL statement has been provided in the answer area. Provide the complete code.
A. Please review the part for this answer
What about “Use two-part names to reference tables.”
SELECT ProductCatlog.CatId, ProductCatlog.CatName,ProductCatlog.ProductID,ProductCatlog.ProdName,
ProductCatlog.UnitPrice,
RANK() Over(Order By ProductCatlog.UnitPrice Desc) As PriceRank
FROM Sales.ProductCatlog
Order By ProductCatlog.UnitPrice Desc
In the question it says “Return rows ordered by descending values in the UnitPrice column.”
SELECT CatID, CatName, ProductID, ProdName, UnitPrice, RANK() OVER(ORDER BY UnitPrice DESC) AS PriceRank
FROM Sales.ProductCatalog
ORDER BY PriceRank DESC
disregard the upper comment..
SELECT CatID, CatName, ProductID, ProdName, UnitPrice, RANK() OVER(ORDER BY UnitPrice DESC) AS PriceRank
FROM Sales.ProductCatalog
ORDER BY UnitPrice DESC
SELECT CatID, CatName, ProductID, ProdName, UnitPrice, RANK() OVER(ORDER BY UnitPrice DESC) AS PriceRank
FROM Sales.ProductCatalog
ORDER BY PriceRank