Wednesday, March 7, 2012

newbie ?

I have a table that has an id field and a description field... Unfortunately
the id field does contain dupicate id entries...
What I need to do is select each distinct id and then one of the many
description fields that are assigned to the id number
can anyone help with thisIf you wanna have the duplicates display:
Select IDField,DescriptionField from SomeTable
WHERE IDField in
(SELECT IDField
From SomeTable
HAVING COUNT(*) > 1
)
Having the distinct values displayed, you should change the Having clause
for HAVING COUNT(*) = 1
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"sqlnewbie67" <sqlnewbie67@.discussions.microsoft.com> schrieb im Newsbeitrag
news:908F1A7A-2F7A-422E-8E58-7FA9A5048184@.microsoft.com...
>I have a table that has an id field and a description field...
>Unfortunately
> the id field does contain dupicate id entries...
> What I need to do is select each distinct id and then one of the many
> description fields that are assigned to the id number
> can anyone help with this|||hello ,
SELECT DISTINCT id, Description from yourtablename
Let us know if it helps....
cheers,
siaj
"sqlnewbie67" wrote:

> I have a table that has an id field and a description field... Unfortunate
ly
> the id field does contain dupicate id entries...
> What I need to do is select each distinct id and then one of the many
> description fields that are assigned to the id number
> can anyone help with this|||Select id, min(Description)
From Table
Group By id
"sqlnewbie67" wrote:

> I have a table that has an id field and a description field... Unfortunate
ly
> the id field does contain dupicate id entries...
> What I need to do is select each distinct id and then one of the many
> description fields that are assigned to the id number
> can anyone help with this

No comments:

Post a Comment