Re: What is max doing across fields in a de-duplication ?

From: Ed prochak <ed.prochak_at_magicinterface.com>
Date: 13 Feb 2004 11:12:41 -0800
Message-ID: <4b5394b2.0402131112.43e01eb_at_posting.google.com>


janik_at_pobox.sk (Jan) wrote in message news:<81511301.0402100246.11a3feb4_at_posting.google.com>...
> I have no idea, but let`s guess - it will return the max values of the
> rows for each custid?
>
> jack_posemsky_at_yahoo.com (Jack) wrote in message news:<209b7e58.0402080701.31e92c77_at_posting.google.com>...
> > Greetings folks,
> >
> > Just curious if anyone knows what the following would produce:
> > SELECT
> > MAX( ECP_SUPPORT_DED_EMAIL.CD_TYP_CMPGN) CD_TYP_CMPGN,
> > MAX(ECP_SUPPORT_DED_EMAIL.CELL_ID) CELL_ID,
> > ECP_SUPPORT_DED_EMAIL.CLIC_CUST_ID CUSTID,
> > MAX( ECP_SUPPORT_DED_EMAIL.ADDRESS) CONTACTED_PARTYID,
> > MAX( ECP_SUPPORT_DED_EMAIL.CONTACTED_PARTY_ID_TYPE )
> > FROM
> > ECP_SUPPORT_DED_EMAIL
> > group by CUSTID
> >
> > For a given CUSTID, and assuming all fields are character and there
> > are duplicates, will it randomly select the MAX value of any of these
> > fields across duplicates, or will it randomly select a custID and
> > retain that row's attributes with integrity?
> >
> > thanks!
> > Jack

First there is nothing RANDOM about it.

MAX() returns the largest value of the COLUMN.

so for mytable:

cmpgn     cell     custid
xxxx      abc      234
aaaa      xyz      234

select max(cmpgn), max(cell), custid
from mytable group by custid ;

returns
max(cmpgn) max(cell) custid
xxxx xyz 234

hth,
  ed Received on Fri Feb 13 2004 - 20:12:41 CET

Original text of this message