I have a database, with a few tables. One of them is a customer table, one of them is a rental table, and one of them is a rental details table. Let’s call them C, R and RD respectively. RD has the date_in and date_out of the tools rented, and is linked to R by RD‘s primary key. R is linked to C by customer id.
Basically what I want to do is select (and delete) customers that have not rented anything in the past 3 years. So I can’t use where date_out > sysdate - 3 years [representation not accurate code] because the tool might have been rented out 4 years ago and ALSO last week, so it needs to be kept in the database… I just need to delete tools that haven’t been rented at all in the past 3 years.
I know the database structure is retarded but I can’t change it.
1 Answer