SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Can i select all values from table w/o duplicates?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

iNko
Starting Member

Lithuania
19 Posts

Posted - 12/09/2012 :  09:18:14  Show Profile  Reply with Quote
Hello, i have a table witch has 3 columns:

Table1
ID GROUP_NAME USER
1 Administrator John
2 Administrator Dave
3 Moderator James
4 IT Tom

I want to show all group names, without showing duplicates, can i do this?

Example:
SELECT GROUP_NAME FROM Table1

Result:
Administrator
Administrator
Moderator
IT

What i want to display:
Administrator
Moderator
IT

Please help

sodeep
Flowing Fount of Yak Knowledge

USA
7174 Posts

Posted - 12/09/2012 :  10:16:19  Show Profile  Reply with Quote
SELECT distinct GROUP_NAME FROM Table1

Or you want to show individual name per group

Select * from
(SELECT *,ROW_NUMBER() OVER(PARTITION BY GROUP_NAME ORDER BY USER)as Seq
FROM Table1
)P
Where Seq = 1
Go to Top of Page

iNko
Starting Member

Lithuania
19 Posts

Posted - 12/09/2012 :  10:47:13  Show Profile  Reply with Quote
Thank you!
Go to Top of Page

sodeep
Flowing Fount of Yak Knowledge

USA
7174 Posts

Posted - 12/09/2012 :  11:04:41  Show Profile  Reply with Quote
NP
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000