I have a table which contains the following columns:
+------------------+----------+
| date_of_purchase | product |
+------------------+----------+
| 2013-06-18 | A |
| 2013-07-18 | A |
| 2013-08-24 | A |
| 2013-10-21 | A |
| 2013-11-20 | A |
| 2013-12-20 | A |
| 2014-01-20 | A |
| 2014-03-24 | A |
| 2014-03-24 | B |
| 2014-04-23 | B |
| 2014-04-23 | A |
| 2014-05-16 | B |
| 2014-05-23 | A |
+------------------+----------+
And I want to get something like this:
+----------+----------+------------+------------+
| product1 | product2 | date_a | date_b |
+----------+----------+------------+------------+
| A | B | 2014-01-20 | 2014-03-24 |
| A | B | 2014-03-24 | 2014-04-23 |
| B | A | 2014-05-16 | 2014-05-23 |
| A | B | 2014-04-23 | 2014-05-16 |
+----------+----------+------------+------------+
What I am trying to do is to check which product "B" is bought after product "A". I am new to stack-overflow, so the way I am asking this question might seem vague. But need help on this one.