PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Fred Cathey <fcathey at advtech dot uswest dot com>
Subject: Re: A Way Side Question
Date: Aug 30 1999 2:50PM

I just got back from Florida (boy it was hot there) and didn't see where this
was answered.  If it already has been, please excuse my repeat.  Anyway, here's
the way to do that:
select what,color,sex from TABLE
group by what,color,sex

The group by clause will remove the duplicate entry

Fred

Charles Zhao wrote:

> Well, this is not a DBLib question.  It's a pure SQL question, but since we
> all deal with SQL, you might have good ideas:
>
> I have table with records like this:
> WHAT    COLOR   SEX     ...
> ==============================
> cat     black   male    ...
> bird    red     male    ...
> cat     white   female  ...
> cat     grey    female  ...
> cat     black   male    ...
> bird    white   female  ...
>
> I need to select records from this table with distinct combinations of the
> above 3 columns.  Thus duplicate rows like "cat black male ..." will be
> eliminated from my selection.  How can do it?
>
> 1.  "select distinct * from .." is not a choice;
> 2.  How does this work: "select distinct WHAT, distinct COLOR, distinct SEX
> from ..."?
>
> Thanks
>
> Charles Zhao