Date Difference between the latest date and second latest date in MySQL

Viewed 122

I have a table where I want to get the list of users who latest transaction created_date subtracted by second latest created_date should be equal to or more than 180 days.

Here's how my table looks like:

enter image description here

Sample Data:

enter image description here

Basically, I want to get list of only those user_id whose difference between the latest created_at date and second latest created_date is greater than or equal to 180 days. So in the above example, the query should only give me user_id '1' in the output.

0 Answers
Related