You may sometimes want to query further on query results in order to make the querying logic simple. I’ve used views to do that in the past when the underlying query has to be reused over and over again. But for temporary purposes, you could use the SELECT query results as a table and query over it.
I wanted to filter results from a table and then group the results further. I filtered the data using a select statement and used it as a table for the outer query for grouping.
SELECT t.server, count(*), report_date FROM (SELECT * FROM kw_server_raw WHERE data LIKE '%microsoft_reporting%' AND report_date < '8/5/2016' ORDER BY id, report_date) t GROUP BY t.server, report_date;