Rows Where the Value Changed
Hard
Query Patterns
A status log lists the status of each entity over time. Return only the rows where the status differs from the previous row of the same entity (the first row always counts). Order by id.
Table schema
StatusLog(id INT PRIMARY KEY, entity VARCHAR(5), status VARCHAR(10))Sample data
id | entity | status
1 | A | new
2 | A | new
3 | A | active
4 | A | active
5 | A | closed
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.