[Zope] RE: converting SQL select list into unique values

Nemeth Miklos nemeth@iqsoft.hu
Sat, 08 Jan 2000 23:15:25 +0100


> Darcy Clark wrote:
> >
> > I have a non-unique column in a MySQL table - I have looked hard for a
> > way in SQL to convert the results of a SELECT into a list of unique
> > values. I know how to define a table at CREATE to have UNIQUE columns
> > but this is not what I want to do.
> >
> > For example :
> >
> > If the result of the SELECT is :
> > 1, 3, 3, 4, 2, 6, 8, 9, 4, 2, 3, 6
> >
> > I would like to return:
> > 1, 2, 3, 4, 6, 8, 9
> >
> > i.e. only the unique values of the list.
> >
> > any pointers ? if SQL can't do this, can Zope ? (I'm sure Zope can do
> > it, it can do everything :)
> >
> > Darcy
>
> If I remember right...
>
> select not_unique
> from table
> GROUP BY not_unique;
>
> The group by aggregate will do the thing you ask for.
>
The standard way is:

select distinct col1
from T

NM