Hoping someone can help me do this the cleanest way possible. I have a Stored Procedure which has some variables and a Select statement. Here is the pseudo code of what I need to do. I have written the pseudo code in the only way I can think to code this, which I know will work, but I'm wondering if there's a cleaner way to do it. Thanks!

var pid
if pid = 0
select trimprobeinfo, a, b, c
from table a join table b on (a.1 = b.1)
join trimprobe on (b.2 = trimprobe.2)
else
select a, b, c
from table a join table b on (a.1 = b.1)
endif