This is a trick to return either YES if there's at least one matching row, or null if not.
Select isnull( SELECT MAX('YES') FROM dbo. ProblemInfo WHERE ProblemID IN (100,101,309,305,205,600,500) AND DEPID = '10866'), 'NO') This is a trick to return either YES if there's at least one matching row, or null if not. The wrapping isnull call then turns a null into a NO.
Try SELECT CASE WHEN (SELECT COUNT(ProblemID) FROM dbo. ProblemInfo WHERE (ProblemID IN (100,101,309,305,205,600,500)) AND (DEPID = '10866')) > 0 THEN 'YES' ELSE 'NO' END FROM YourTable.
This is about where I was starting to head with my query. I do not use SQL regularly so I forget the finer points. T – Ray 8 hours ago @Ray glad to be of help :-) please don't forget to accept any answer that helped (see meta.stackoverflow.Com/questions/5234/…).
– Yahia 8 hours ago.
If you are using oracle you can use case when. SELECT case when COUNT(ProblemID) = 0 then 'NO' else 'YES' end FROM dbo. ProblemInfo WHERE (ProblemID IN (100,101,309,305,205,600,500)) AND (DEPID = '10866').
Interesting. I forgot to mention that I am using MS SQL however this is a good query to keep handy. Thanks – Ray 8 hours ago.
Here's an alternate way of querying that. IF EXISTS( SELECT * FROM dbo. ProblemInfo WHERE (ProblemID IN (100,101,309,305,205,600,500)) AND (DEPID = '10866') ) BEGIN SELECT 'Yes' END ELSE BEGIN SELECT 'No' END What I like about this method is that, for enormous data-sets, it should be noticeably faster.
Ts is especially interesting. While speed is always not a huge factor but it is important to be aware of. I will have to try this out this query.
I appreciate the help very much. – Ray 8 hours ago.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.