Re: Distinct rows

From: Simon Hedges <shedges_at_hhhh.freeserve.co.uk>
Date: Sat, 23 Oct 1999 10:46:37 +0100
Message-ID: <7us08o$c6r$2_at_news7.svr.pol.co.uk>


> > 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

How about select vendorid, product, max(description) group by vendorid, product.

This will always give you the Description that is the highest in the alphabet. The other option is to specify 'Description = 'RKS', or to add a description_order column.

Simon Hedges
Gloucester
UK Received on Sat Oct 23 1999 - 11:46:37 CEST

Original text of this message