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.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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/SQL/message.cfm/messageid:2594
Subscription: http://www.houseoffusion.com/groups/SQL/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.6