I have a subquery that I need to join to but that has null values in the second and non-primary key column I am linking to (I have two links between the subquery I am using for the query, one to the primary and the second, as mentioned in the preceding sentences, to a non-primary). Luckily, when I need the data where the non-primary key column is null, I don't need to link to that column. So, I am trying to use a CASE statement to run the single link query when the non-primary key is null, and the double link query when the non-primary key is not null. I keep getting the error "Only one expression can be specified in the select list when the subquery is not introduced with EXISTS. Here is the query:

Thank you visakh16 for taking the time to help me. The more time I spent working on this query the more I realized the basic logic behind it is flawed. I went back to the drawing board and found a much simpler solution. So, I am abandoning this approach in favor of a simpler and hopefully faster one. Thank you again.