SQL Server and DISTINCT -


i have been spending hours of googleing , searching way solve problem can't find anything.

i have 2 tables: table1 , table2 , want find unique emails in table1 not present in table2.

the first query returns int result of 1420 , second query returns row set total count of 1431.

how possible? guess has fact select name , status well?

select      count(distinct(email))      table1 t1       t1.siteid = 4      , t1.email not in (select email table2 t2 t2.siteid = 4) go  mypage (    select distinct(t1.email),         t1.name,         t1.[status],        row_number() on (partition t1.email order t1.name) apperences,        row_number() on (order t1.name) rownumber            table1 t1             t1.siteid = 4         , t1.email not in (select email table2 t2 t2.siteid = 4) ) select      email, name, [status]      mypage      rownumber => 0 , rownumber <= 50000 

i know add "distinct" on last select screw paging have...

try this:

with mypage    (select        t1.email,        t1.name,        t1.[status],       row_number() on (partition t1.email order t1.name) apperences,       row_number() on (order t1.name) rownumber    table1 t1     t1.siteid = 4     , t1.email not in (select email table2 t2 t2.siteid=4)   )  select email, name, [status] mypage rownumber => 0 , rownumber <= 50000 , apperences = 1 // give distinct email 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -