Rename SQL query to SQL Query with Regular Expression and Subquery