0
votes

I am trying to create a query that displays no data if false. Right now I have my query and the false portion of my IIF query is "". That is displaying an empty box for that field. I want my query to show no box at all. Can I do that with an IIF statement? Maybe I need a WHERE clause? SQL statement is below:

SELECT
IIF(s.[Destroyed(yes/no)] = "no", s.Station_ID, "") AS Active_Stations, p.Days_Till_Next_Measure

FROM (Status AS s LEFT JOIN [Priotitization #2] AS p On s.Station_ID = p.Station_ID)
2

2 Answers

1
votes
SELECT
IIF(s.[Destroyed(yes/no)] = "no", s.Station_ID, "") AS Active_Stations, p.Days_Till_Next_Measure
FROM (Status AS s LEFT JOIN [Priotitization #2] AS p On s.Station_ID = p.Station_ID)
WHERE 1 = IIF(s.[Destroyed(yes/no)] = "no", 1, 2) 

Does this work? I didn't try this cause I dont have Access.

0
votes

You want a WHERE clause to filter rows. You can't filter rows in the SELECT. So:

SELECT IIF(s.[Destroyed(yes/no)] = "no", s.Station_ID, "") AS Active_Stations,
      p.Days_Till_Next_Measure
FROM Status AS s LEFT JOIN
     [Priotitization #2] AS p
     On s.Station_ID = p.Station_ID
WHERE s.[Destroyed(yes/no)] = "no";