Day 8/21 – SQL Challenge
Day 8/21 – SQL Challenge
Solved 4 SQL questions today, mainly using window functions, self joins, and subqueries.
• Rising Temperature:
Used LAG() to compare today’s temperature with yesterday’s and filtered where today > previous day.
(Also possible using self join with date difference logic.)
• Customers Who Never Order:
Solved using
1.LEFT JOIN + NULL filter
2.NOT EXISTS subquery
• Repeated Payments (DataLemur):
Used LAG() to get previous transaction timestamp and calculated time difference.
Filtered payments repeated within 10 minutes for same card, merchant, and amount.
• Employees Earning More Than Their Manager:
Solved using self join on employee_id and manager_id and compared salaries.
Key learning:
Window functions + self joins make comparison-based problems much easier.
Day 9 loading…
Comments
Comments from the original post on Instagram
No comments yet
