Time for action – modifying the SQL query