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
 General SQL Server Forums
 New to SQL Server Programming
 sql query need help

Author  Topic 

rajnidas
Yak Posting Veteran

97 Posts

Posted - 2014-09-23 : 08:56:49

hi all

when i execute folowing query

select t.FileTypeId from (select distinct FileTypeId from UploadFile_Master where FileTypeId in (select id from File_Master
where id between 16 and 21) AND Upload_Date='2014-09-01' AND IsActive=0)t

getting result
------------------
FileTypeId
--------------
16
17
18
19
20
21


need result
--------------------

if FileTypeId is 20 and 21 is missing then result should be only

20 and 21 should come . pls need help

thanks & regards

rajnidas

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-09-23 : 09:23:05
quote:
if FileTypeId is 20 and 21 is missing then result should be only

20 and 21 should come . pls need help
I am not able to understand what you are saying here. Can you rephrase it and/or show some examples?
Go to Top of Page

Nevarda
Starting Member

5 Posts

Posted - 2014-09-23 : 10:32:29
If I understand your query correctly, when it selects the ID from the File_Master in the last sub-query and returns a result that includes 21, that immediately tells me that 21 is not missing and hence your query works. if 20 did not exist, it would not be included in the result set.
Or am I maybe missing some information?
Go to Top of Page
   

- Advertisement -