I am trying to create a query in which one of two queries is run depending on a specific result. I have Table A and Table B. Table B is sometimes NULL, so I wanted the query to say that if Table B is null, run this query pulling data from Table A, but if Table B is NOT null, then run the query pulling data from Table B.
I tried a switch function as well as an iif, but neither worked. Not sure if that's because I messed up the syntax or if neither of these are valid ways of writing this query?
SELECT
SWITCH(
DCOUNT("*",Table_B) = 0,
(SELECT *
INTO Result_Table
FROM Table_A),
DCOUNT(*,Table_B) <> 0,
(SELECT *
INTO Result_Table
FROM Table_B)
SELECT
IIF(DCOUNT(*,Table_B) = 0,
(SELECT *
FROM Table_A),
(SELECT *
FROM A))
Thank you in advance!