Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 CTE

Author  Topic 

yadhu_cse
Constraint Violating Yak Guru

252 Posts

Posted - 2011-02-28 : 23:42:57
Hi,

i am writing common table expression to retrive data from table like

With CTE
AS
(select *from dbo.EnquiryDetails where webstatusflag=0

),
CTE1 as
(select *from dbo.EnquiryDetails where webstatusflag=1)


NOw i wnat to display cte data which should not present in cte1
i have matching filed in cte and cte1 that is email id and registration no.

how to get the result can any ane tel.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-03-01 : 01:46:01
[code]
select *
from cte c
where not exists
(
select *
from cte1 x
where x.emailid = c.emailid
and x.registrationno = c.registrationno
)
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

yadhu_cse
Constraint Violating Yak Guru

252 Posts

Posted - 2011-03-01 : 02:28:35
Thanks
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-03-01 : 02:37:53
sorry, the condition should be "NOT EXISTS"


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -