You have a table named *Products* with the following schema:

Syed Shah Hussain Bukhari 140 Reputation points

You have a table named Products with the following schema:

  • product_id (Primary Key)
  • product_name
  • price
  • stock_quantity

How to write an SQL query to retrieve the names of the top 5 most expensive products along with their prices. Order the results from the highest price to the lowest?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
10,920 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Erland Sommarskog 87,271 Reputation points

    Can you please tell us why we should write the query for your class assignment or interview question for you? I will give you the hint that you can achieve this with the TOP clause or the row_number function.

    0 comments No comments

  2. CosmogHong-MSFT 14,666 Reputation points Microsoft Vendor

    Hi @Syed Shah Hussain Bukhari

    Check this:

    Select Top(5) product_id,product_name,price
    from Products
    Order by price DESC

    Best regards,

    Cosmog Hong

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  3. Muhammad Binyameen 380 Reputation points

    To retrieve the names of the top 5 most expensive products along with their prices in SQL Server, you can use the following SQL query:

    SELECT product_name, price
    FROM Products
    ORDER BY price DESC
    LIMIT 5;

    This query selects the product_name and price columns from the Products table and orders the results in descending order of the price column. The LIMIT 5 clause ensures that only the top 5 most expensive products are returned.

    Please note that the syntax and functionality of SQL queries can vary slightly between different database management systems. So, make sure to adjust the query if you are using a different database system than SQL Server.

    0 comments No comments