That won't work. You have to include all the fields in your select statement
in your group by clause.

Duane

-----Original Message-----
From: William Bowen [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 30, 2006 3:17 PM
To: CF-Community
Subject: Re: SQL Question

Group By Email?

On 10/30/06, Duane <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I have a sql question for anyone willing to help me get my head unstuck.
>
>
> I have the following sample data:
>
> RegDate FirstName       LastName        Email
> 10/1/2006       NULL            NULL            [EMAIL PROTECTED]
> 10/2/2006       NULL            NULL            [EMAIL PROTECTED]
> 10/2/2006       NULL            NULL            [EMAIL PROTECTED]
> 10/3/2006       Fred            Flintstone      [EMAIL PROTECTED]
> 10/8/2006       Barney  Rubble  [EMAIL PROTECTED]
> 10/9/2006       NULL            NULL            [EMAIL PROTECTED]
>
> In my returned dataset I need to get the following:
> 10/1/2006       NULL            NULL            [EMAIL PROTECTED]
> 10/2/2006       Fred            Flintstone      [EMAIL PROTECTED]
> 10/8/2006       Barney  Rubble  [EMAIL PROTECTED]
>
> Basically I need all records that have a first and last name, and only the
> null records that have a distinct email address.
>
> I had written the following:
>
> select  RegDate, Firstname, Lastname, Email
> from            dbo.LitRequest
> where           (FirstName is not null or FirstName <> '')
>                 or l.Email not in (
>                         select Email from dbo.LitRequest
>                         where FirstName is not null or FirstName <> '')
>
> The only thing I can think of is to use a cursor and generate a temp table
> on the fly. Cursors tend to be processor hogs and I'm looking for an
> alternative.
>
> Thanks,
> Duane
>
>
>
>
>
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Community/message.cfm/messageid:218737
Subscription: http://www.houseoffusion.com/groups/CF-Community/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.5

Reply via email to