Company: Amazon_data engineer role_22july
Difficulty: medium
Problem Description Amazon Route 53, AWS's domain name registration service, requires new reporting functionality. Create a SQL query that returns a list of all active accounts, the number of unexpired domain names they have, and the nearest expiration date later than July 15, 2022. The result must have the following columns: username , domains , nearest_expiration . username — AWS account username. domains — total number of (unexpired) domains for that account. nearest_expiration — nearest expiration date among that account's unexpired domains. The result should be sorted in ascending order by username . Notes Only active accounts ( is_active = 1 ) should be included in the report. Only domain names that have not expired (expiration date strictly greater than today) should be included in the report. Today is July 15, 2022. A domain expiring exactly on 2022-07-15 is therefore not counted. An account with no unexpired domains does not appear in