Re: Distinct rows

From: Yosi Greenfield <yosi_at_newsalert.com>
Date: Fri, 22 Oct 1999 13:02:21 -0400
Message-ID: <3810989D.FA3BA504_at_newsalert.com>


It's really your logic that needs a little straightening. Which description do you want? RKS or DDK? You've got to tell Oracle which to pick. If you don't care which description it uses, use a group function like min.

Either use:

   select vendorid, product, min(description)    from vendors
   where vendorid < 100
   group by vendorid, product;

or just leave out description:

   select vendorid, product
   from vendors
   where vendorid < 100;

HTH, Yosi

Chris Jordan wrote:

> well, this doesn't work either. Because 'distinct' refers to entire record.
> I want distict vendors. So from the example
> below, only two records get returned instead of three as there are only 2
> distinct VENDORS even though there are
> 3 distinct RECORDS.
> Peter Okhiria <peter.okhiria_at_mci.com> wrote in message
> news:38103931.A35CDAE2_at_mci.com...
> > use
> > select distinct vendorid, product, description from vendors where
> > vendorid < 100
> >
> > Chris Jordan wrote:
> >
> > > Hi I have a query (select vendorid, product, description from vendors
> where
> > > vendorid < 100) that is returning duplicate information, ie.
> > > VENDORID PRODUCT DESCRIPTION
> > > 1 Switches RKS
> > > 1 Switches DDK
> > > 2 UPS New
> > >
> > > What query can I use that displays only one instance of a specifc
> vendor,
> > > i.e in the above, only vendorids 1 & 2 are
> > > displayed for a total of two records(1,switches,RKS) and (2,UPS,New).
> > >
> > > Thanks,
> > > Chris
> >
> >
> >
Received on Fri Oct 22 1999 - 19:02:21 CEST

Original text of this message