I need to write a sql select query on a table, but I have 1 special condition that I have problem with. My table structure is like below:
ID Name Serial CreatedOn
1 A 1000 2014-10-10
2 A 1000 2014-10-12
3 A 1000 2014-12-12
4 B 1023 2014-10-01
My query should compare createdon dates, if there is 1 or more records that names and serials are the same and the createdon date is less than 1 month older than the other ones, they need to be removed. For instance, in my example table, row with ID=2 should be removed from my select query because it has the same data as the first row and the date is less than 1 month older, but it should show the third row since the createdon date is more than 1month older.
How can I write this select query?
Thanks,