Most solutions here are missing the latest testcase no 13 of "number in the domain" | Updated sol
The testcase 13 says that the test cases where the domain name contains numbers (e.g., username@123domain.com,test@domain123.com)I have reported the missing tes
# The testcase 13 says that the test cases where the domain name contains numbers (e.g., username@123domain.com,test@domain123.com)
**I have reported the missing test case myself on the leetcode platform. So here is the updated code which runs all test cases**
# Intuition
This query selects users with properly formatted .com email addresses. It first checks that the email contains exactly one @ symbol and ends with .com. Then, it ensures the username (the part before @) contains only letters and numbers, meaning no special characters like !, _, or #. Finally, it verifies that the domain name (the part between @ and .com) consists of only letters, ensuring there are no numbers or special symbols. This helps filter out incorrectly formatted emails and keeps the data clean.

# Code
```mssql []
SELECT * FROM users
WHERE 
    -- Ensure the email contains exactly one '@' symbol
    LEN(email) - LEN(REPLACE(email, '@', '')) = 1 
    
    -- Ensure the email ends with '.com'
    AND email LIKE '%.com' 
    
    -- Ensure the part before '@' (username) contains only letters and numbers
    AND LEFT(email, CHARINDEX('@', email) - 1) NOT LIKE '%[^a-zA-Z0-9]%' 
    
    -- Ensure the domain name (between '@' and '.com') contains only letters
    AND SUBSTRING(email, CHARINDEX('@', email) + 1, CHARINDEX('.com', email) - CHARINDEX('@', email) - 1) 
    NOT LIKE '%[^a-zA-Z]%';

```
['MS SQL Server']