I'm trying to show count of users and what type of users they are based on their age in the ranges provided, their gender, and the average trip duration. This is my current SQL: I receive a syntax error on the highlighted from, but why?
select count(distinct(usertype)), gender, avg(tripduration),
extract(year from current_date) - birth_year as age,
from(select age,
case
when age <25 then "Under 25"
when age between 26 and 35 then "26 to 35"
when age between 36 and 45 then "36 to 45"
when age between 46 and 55 then "46 to 55"
when age > 55 then "Over 55"
else "Invalad Birthdate"
from `project-1-349215.Dataset.tripdata` -- this from
end as agerange)
`project-1-349215.Dataset.tripdata`
where bikeid is not null
group by usertype, gender, age