I have a purchase_log table which has the following fields:
uid, date, category, amount
And I would like to know the first and second purchases dates for each user of each category.
For example:
+-----+------+----------+--------+
| uid | date | category | amount |
+-----+------+----------+--------+
| A | d1 | c1 | 100 |
| A | d2 | c2 | 200 |
| A | d3 | c1 | 120 |
| A | d4 | c2 | 300 |
+-----+------+----------+--------+
For above user records, I would like to say the first purchase from category c1 is made on date d1, and second purchase from category c1 is made on date d3.
I currently created 3 calculated fields:
1st purchase:
{ FIXED [uid] : MIN([date])}
Repeat purchase:
IIF([date]>[1st Purchase],[date],null)
2nd purchase:
{ FIXED [uid] : MIN([Repeat Purchase])}
But since there is no distinction between categories, I'm not able to see dates with respect to categories.
How should I solve this problem?
Thanks.