Try this:

select email, max(customerid) ci from customers
group by email
order by ci desc;

At 02:57 PM 3/8/2004 -0600, you wrote:
>Perhaps a subquery:
>
>
><CFQuery name="getcustomer" datasource="printprices">
>SELECT email, customerid
>FROM customers
>Where customer != 'test'
>AND email in  (select distinct email from customers)
>Order by customerid desc
></cfquery>
>
>
>-----Original Message-----
>From: Robert Orlini [mailto:[EMAIL PROTECTED]
>Sent: Monday, March 08, 2004 2:08 PM
>To: CF-Talk
>Subject: SOT: Distinct
>
><CFQuery name="getcustomer" datasource="printprices">
>SELECT distinct email, customerid
>FROM customers
>Where customer != 'test'
>Order by customerid desc
></cfquery>
>
>In the above Query, how do I distinct just the email and not the customerid.
>Because of the Order by SQL requires me to put customer id in the Distinct
>part of Select. This throws things off since some customers have distinct
>customerid's but their emails are similar.
>
>How do I do an order by customerid, but still display just distinct email
>addresses not duplicates?
>
>Thx.
>
>Robert O.
>HWW
>   _____
>
>----------
>[
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to