Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How will get distinct records in SQL table?

Author  Topic 

sql-programmers
Posting Yak Master

190 Posts

Posted - 2013-12-25 : 23:40:54
For examble:

In a table name like

1.Test
2.Test.
3.Test..
4.Test...

How will get the name "Test" using distinct keyword?

SQL Server Programmers and Consultants
http://www.sql-programmers.com/

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-12-26 : 03:14:30
[code]
SELECT DISTINCT Column FROM table
[/code]
Where column is the column containing Test as value

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-12-26 : 03:58:08
In case what you've is the full value within the column as shown above, what you need is this

SELECT DISTINCT STUFF(Column,1,CHARINDEX('.',Column),'') FROM table


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -