2011-01-10 12 views
1

私はselect fallowingクエリを書いていますが、クエリでは驚くべき結果が得られます。 plsは私に知らせる。クエリ:クエリの選択結果が異なる

Select count(*) Count from conflux.dbo.SABR_Master M 
     Where M.Email in (
     select top 26 Email from conflux.dbo.SABR_Master L 
     where (L.titleid In (Select titleid From sabr_titlemasters Where IsDisplay=1 And title like '%Account Executive%' OR title like '%Account Manager%' OR title like '%Accounts Manager%' OR title like '%admin%' )) 
     ) and M.Email NOT IN (select Email from [sample client].dbo.Comm_CompanyData) 
+0

plsはそれをあなたのクエリにフォーマットします –

答えて

1

この

Select count(*) Count 
from conflux.dbo.SABR_Master M 
Where M.Email in (select top 26 
          L.Email 
        from conflux.dbo.SABR_Master L 
        where (L.titleid In ( Select titleid 
              From sabr_titlemasters 
              Where IsDisplay=1 And 
                (title like '%Account Executive%' OR 
                title like '%Account Manager%' OR 
                title like '%Accounts Manager%' OR 
                title like '%admin%'))) 
        ORDER BY L.Email) and 
     M.Email NOT IN (select Email 
         from [sample client].dbo.Comm_CompanyData) 

を試してみてください私は、同じあなたの26通の電子メールを保つためにあなたの ORのようなタイトルと秩序の周りにブラケットを追加しました。データベースは、order byが指定されていない場合はランダムな順序で返すことができ、異なる結果が得られます。

+0

あなたの 'M.Email NOT IN'はサブクエリではなくクエリ全体に適用されています。 – cjk

+0

良いピックアップは、それを更新する –

+0

ありがとうジョン。ありがとうございました – sreekanth

関連する問題