---
title: "Distinct Data in SQL Server"  
description: "How do I display only unique records from my table?  For demonstration first we create a table--USE DATABASE  USE AVI  --CREATE TABLE  CREATE TABLE Pr"  
author: "AVADHESH PATEL"  
published: 2012-11-01  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/384/distinct-data-in-sql-server  
category: "database"  
tags: ["database"]  
reading_time: 1 minute  

---

# Distinct Data in SQL Server

How do I display only [unique records](https://www.mindstick.com/forum/157534/how-to-count-all-unique-records-in-the-sql-table) from my [table](https://www.mindstick.com/articles/43918/how-to-design-table-using-bootstrap)?\

For demonstration first we create a table

```
--USE DATABASEUSE AVI--CREATE TABLECREATE TABLE Product_Info (ID INT, Product VARCHAR(100), Price INT, Color VARCHAR(100))GOINSERT INTO Product_InfoSELECT 1, 'Toy', 100, 'Black'UNION ALLSELECT 2, 'Pen', 100, 'Black'UNION ALLSELECT 3, 'Pencil', 100, 'Blue'UNION ALLSELECT 4, 'Pencil', 100, 'Red'UNION ALLSELECT 5, 'Pencil', 200, 'Yellow'UNION ALLSELECT 6, 'Cup', 300, 'Orange'UNION ALLSELECT 7, 'Cup', 400, 'Brown'GOSELECT Product, Price, ColorFROM Product_InfoGO
```

##### Screen Shot

![Distinct Data in SQL Server](https://www.mindstick.com/blogs/360ac59f-be04-4c44-b3d1-c02f37a0d25f/images/200bf70c-7c98-4f51-981a-1fe13e2984ef.png)\

Now we going to filter the distinct record based on column name

```
SELECT Product, Price, ColorFROM(SELECT Product_Info.*,ROW_NUMBER() OVER (PARTITION BY Price ORDER BY Price DESC) AS RNFROM Product_Info) AS tWHERE RN = 1ORDER BY IDGO
```

##### Screen Shot

![Distinct Data in SQL Server](https://www.mindstick.com/blogs/360ac59f-be04-4c44-b3d1-c02f37a0d25f/images/96b96dee-c8fa-482c-85f2-079e6b05ca87.png)

---

Original Source: https://www.mindstick.com/blog/384/distinct-data-in-sql-server

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
