Question : Select Statement

How do I modify the attached statement to include where @dealID is not in a second table (tblEmails)
1:
2:
3:
4:
5:
6:
7:
8:
declare @dealID int
Set @dealID = (
	Select top 1 dealID
	from CRMPROD_01.dbo.P_Events_Table 
	where eventtypeid = @eventTypeID and 
	((convert(char(11),EventData,100)) = '' + convert(char(11),@twoDays,100) + ''
		or
	(convert(char(11),EventData,100)) = '' + convert(char(11),@sevenDays,100) + ''))

Answer : Select Statement

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
declare @dealID int
Set @dealID = (
    Select top 1 dealID
    from CRMPROD_01.dbo.P_Events_Table
    LEFT OUTER JOIN tblEmails
    ON CRMPROD_01.dbo.P_Events_Table.dealID = tblEmails.dealID
    where eventtypeid = @eventTypeID and 
    ((convert(char(11),EventData,100)) = '' + convert(char(11),@twoDays,100) + ''
        or
    (convert(char(11),EventData,100)) = '' + convert(char(11),@sevenDays,100) + '')
    and tblEmails.dealID IS NULL)
Random Solutions  
 
programming4us programming4us