> I want to find anything that is not 10 or 20
WHERE "Activity Code" not in (10, 20)
If it's not obvious how to do a job with DECODE, then maybe DECODE is the wrong tool for the job. Use CASE instead of DECODE.
If I knew exactly what you wanted to do, then I could show you exactly how to do it. (Looking at code that produces the wrong results doesn't tell me what your data is, or what the right results from that data are.)
Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved, so that the people who want to help you can re-create the problem and test their ideas.
Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
Always say which version of Oracle you're using (for example, 188.8.131.52.0).
See the forum FAQ: https://forums.oracle.com/message/9362002
That above replies might already give you answers. I'm trying to guess here that you want to group all other groups (not 10,20) into one single group (assume it's group 0). If that's the case, you can also do
decode(code, 10, 10, 20, 20, 0)
Instead of decode use CASE
CASE when "Activity Code" in (10,20) then NULL else "Activity Code" end
And by the way. "Activity code != 10 or "Activity Code" != 20 is true for every non null activity code, even 10 and 20. If it's = 10 it's still != 20 so the condition is still true.
Admin1, righto again. Thanks... that was exactly what I needed.
Kendenny.. yup, good catch... I was trying to just quickly ask about decode, but yes, you caught me on some crappy logic
Thanks again everyone.