I need to filter the results of a table query based on the result of a nested select.
I currently have the following:
(SELECT Ok1 = case Latitude when '-' then '0' when '' then '0' else '1' end) as Ok1,
(SELECT Ok2 = case Longitude when '-' then '0' when '' then '0' else '1' end) as Ok2
This selects the data from the tblEquipment correctly and creates two new columns 'Ok1' and 'Ok2'
I also wish to filter based on the result of these by adding something like
WHERE Ok1='1' AND Ok2='1'
But I get Invalid column name 'Ok1'
But I get Invalid column name 'Ok2'
Am I doing something that I am not supposed to or do I have the syntax wrong?
Is there a better or more correct way to do this?
Thanks for the help,