sql for either A or B or all?
853700Mar 16 2012 — edited Mar 18 2012Hi,
I would like to accomplish a sql guery for the following situation.
I would like to find all the students who are female or students who are in 3rd grade. But if the request doesn't ask for either gender or grade then show all the students.
Both gender_s and grade_n are variables. If both variables are null then I get the whole school which is fine. When gender_s = female then I still get the whole school. How do I fix my query?
select students from school where
gender = nvl(gender_s, null)
or
grade = nvl(grade_n, null)
union
select students from school
....
Thanks for any help in advance.