More work on SQL syntax, rewrite SQL expressions to SQL queries