Hi
I am trying to write some SQL that pulls from several tables using unions, where the date on the rows is less than a hour.
But if the total rows from the SQL query doesn't add up to about 20 then it should change the where to the date being less than two hours and so forth until 20 rows retrieved.
Is this possible to do solely in SQL? I have a way of implementing it using PHP as well, but would prefer to have it all done in SQL.