The error you get comes from the fact that you are trying to use the derived value in the same select clause in which you create it. You will need to do something on these lines:
SELECT count(*) as TotalStates, (SELECT count(*) from states) as NumberStates, (count(*)/(SELECT count(*) from states)) as percentage FROM states WHERE criteria = x
However, this is not very effective or desirable for readability or maintenance. Is there a design reason that you cannot do this in two queries or, even better, get two data elements in separate queries and calculate the percentage in the consuming code?
Joseph Alcorn
source share