Why does this not work?
select *
from
(
select membership_number
from members
where membership_number not like '%[^0-9]%'
) mem
where cast(membership_number as int) > 2
See SQL Fiddle Demo.
The subquery should filter out data that is non numeric, and the outer query is casting this to an integer so that I can look for anything > 2.
It seems like it is running the where clause of the outer query first. How do I get around this?