Let's say I have a table named ages containing one column called age that just contains rows of age integers.
I want to find rows that are less than or equal to the (MAX(age) - MIN(age)).
The approach I first took was doing
SELECT * FROM ages WHERE age <= MAX(age) - MIN(age) which didn't work because we can't use aggregate in the where clause.
IS there anyway one could solve this problem using a sql query?
Two steps:
The query consists of a main query and a subquery: