SQL Percentage of users falling in a specific range I have a list of users with corresponding date of birth.
Is there any possibility I can get a percentage of users born between 1990 and 2000 in a single SQL query?

The query I tried is as follows:

Select (Select count(distinct user) as users from Visitors
  where birthyear between 1990 and 2000)/count(distinct user) from Visitors


But it gives me a zero as result.
SELECT 100.0 * SUM(birthyear between 1990 and 2000) /
               COUNT(*)  AS pct
    FROM ( SELECT userid, MAX(birthyear) AS birthyear
             FROM visitors GROUP BY userid ) AS x


Some notes:


SUM(boolean-expr) is a way to count how often it is TRUE.
between 1990 and 2000 includes 101 distinct years because BETWEEN is 'inclusive'.  Are you sure you wanted that?
COUNT(*) will count all the rows from the derived table (the subquery)
MAX is a kludge -- A visitor might put down different birthyears on different visits.
Whenever a subquery is used, it must have parentheses around it.
The 'composite' index INDEX(userid, birthyear) would help performance some.