SQLTeam.com | Weblogs | Forums

List only distinct results

I am stuck on this the result should have unique names but there are similar names and I do not know how to get this done , what we need is that the result should only have data in which the [name] column has unique values.
This query produces results such as for example.
AliG , 12345
AliG, 54321
AliG, 987654
Coco, 987654
Sammy, 12345
What i want that is that results should have unique values based on name


SELECT DISTINCT COCOAdressen.Name1 as [name]
COCOdressen.LieferStrasse as [street]
,COCOdressen.LieferPLZ as [zipcode]
,COCOAdressen.LieferOrt as [city]
,COCOAdressen.EMail as [EMail]
,COCOAdressen.Telefon as [Telefon]
FROM [COCOJUMBO].[dbo].[COCOAdressen] COCOAdressen INNER JOIN
[COCOJUMBO].[dbo].[COCOKontokorrent] COCOkorrent on COCOkorrent.Adresse = COCOAdressen.Adresse
where COCOAdressen.Gruppe is not NULL
and COCOAdressen.Aktiv = '-1'
GROUP BY COCOAdressen.Name1
,COCOAdressen.LieferStrasse
,COCOAdressen.LieferPLZ
,COCOAdressen.LieferOrt
,COCOAdressen.EMail
,COCOAdressen.Telefon
ORDER BY COCOAdressen.Name1
,COCOAdressen.LieferStrasse
,COCOAdressen.LieferPLZ
,COCOAdressen.LieferOrt
,COCOAdressen.EMail
,COCOAdressen.Telefon

What is the meaning of ..

and COCOAdressen.Aktiv = '-1'

Does this mean you get the past adressen? 1 Name can have multiple inactive addresses? If you want unique columns you must add more logic to make it unique.

please provide some sample data for AliG

[COCOAdressen] COCOAdressen 
[COCOJUMBO].[dbo].[COCOKontokorrent]