I need to select pairs of rows from a table that meet certain criteria.
Here's an SQL fiddle that demonstrates what I want:
http://sqlfiddle.com/#!2/4fc2f/16/0
This works well when the table is small--but the problem is my production table may have millions of rows and thousands of rows for a particular date. Query takes 14-15 seconds to run for a particular date now. How can I improve it?
MySQL 5.5