CASE didn't work?

case statements have worked wonders for me in the past....no need for
unions.

On 10/30/06, Duane <[EMAIL PROTECTED]> wrote:
>
> Whoops, I put the real db name in there but you get the idea.
>
> -----Original Message-----
> From: Duane [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 30, 2006 3:36 PM
> To: CF-Community
> Subject: RE: SQL Question
>
> Yep. I got this off the HOF SQL list:
>
>
> Select DateCreated, FirstName, LastName, Email
> from dbo.IBS_ShowLitRequest
> where coalesce( firstname,'' ) <> '' and coalesce( lastname,'' ) <> ''
>
> UNION
>
> Select min( DateCreated ), firstname, lastname, email
> From dbo.IBS_ShowLitRequest
> Where firstname is null and lastname is null and coalesce( email,'' ) <>
> ''
> group by firstname, lastname, email
>
>
>
>
> -----Original Message-----
> From: Nick McClure [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 30, 2006 3:24 PM
> To: CF-Community
> Subject: RE: SQL Question
>
> The Dreaded Union?
>
> > -----Original Message-----
> > From: Duane [mailto:[EMAIL PROTECTED]
> > Sent: Monday, October 30, 2006 2:29 PM
> > To: CF-Community
> > Subject: RE: SQL Question
> >
> > 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:218747
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