Loading...
Deduplicate and Keep Latest
A medium SQL interview practice problem on DataDriven. Write and execute real sql code with instant grading.
- Domain
- SQL
- Difficulty
- medium
- Seniority
- senior
Problem
The server_logs table contains duplicate entries for the same event. Deduplicate by keeping only the most recent row per combination of server_name and message, using log_timestamp to determine recency. Then from the deduplicated result, return only rows where the log_timestamp falls within the last 7 days. Include all columns.
Practice This Problem
Solve this SQL problem with real code execution. DataDriven runs your SQL queries against a live PostgreSQL database and grades it instantly.