October 29th, 2013, 06:17 AM
Loop databases and select distinct names when criteria not in database
I have a list of databases I need to loop through. I need to pull out all the databases that do not contain a certain type (red in example).
Therefore the query would show me databases 3,4,5 do not contain red. Although database 1 has other colours, it wouldn't show as it has red.
Hope this makes sense, I haven't started the code yet.
Last edited by nickmaca10; October 29th, 2013 at 07:47 AM.
October 29th, 2013, 07:15 AM
having sum(case when type = 'Red' then 1 else 0 end) = 0
Comments on this post
October 29th, 2013, 07:46 AM