Not knowing the relationship between the tables makes it a bit hard. But a basic approach I often take as a starting point would be to put the three queries into 3 subqueries in the FROM clause. Then in the where clause put the join condition between the three subqueries i.e. the variables you use in the second and third queries which depend on the first query.
As for the if..then else.. you can use a CASE statement to emulate this logic. The biggest problem is usually if the 2nd and 3rd queries return multiple rows for one row in the driving (first) query.