I'm running a SELECT query to get data from MySQL
SELECT MIN(datetime) as created, MAX(datetime) as updated, COUNT(CASE WHEN type = 'update' AND contact_name <> 'System' THEN 1 END) as replies, COUNT(CASE WHEN type = 'update' AND (contact_name * 1 = contact_name) THEN 1 END) as customer_replies
And it works fine, but I also want to get the next row after MIN(datetime)
Is it possible to do this like MIN() 1
?
Here is a solution that gives the second smallest value:
When we use LIMIT n, it returns the first n rows, and when we use LIMIT n,m, it returns the m rows after the nth row (excluding the nth row). In our case it doesn't return the first row, only the second row. Since we ordered the query by datetime, the second row is the second oldest.