Oracle语句判断有关问题

Oracle语句判断问题select a1,a2 from a,bwhere a.a1b.b1 原始语句大致如上,现在我想在语句做一个判断,如

Oracle语句判断问题


select a1,a2 from a,b  where a.a1=b.b1 

原始语句大致如上,现在我想在语句做一个判断,如果a1 is null,那么where后面就是a.a1=b.b1;如果a1 is not null,那么where后面就是a2 = b1。
求大神语句如何修改!!!
[解决办法]
select a1,a2 from a,b where (a1 is null and a.a1=b.b1) or (a1 is not null and a.a2=b.b1)
[解决办法]
select a1,a2 from a,b  where case when (a.a1 is null then a.a1 else a.a2 end)=b.b1 
[解决办法]
引用:
select a1,a2 from a,b  where case when (a.a1 is null then a.a1 else a.a2 end)=b.b1


up