How can I retrieve all of the videos rented in the last 30 days
How can I retrieve all of the videos rented in the last 30 days and sort in chronological rental date order.
My code was unsuccessful
CREATE TABLE Rentals(
RentalID INT PRIMARY KEY,
InventoryID INT,
RateID INT,
DateRented DATE,
ReturnDate DATE,
CustomerID INT,
CONSTRAINT fk_Rnt_Inv FOREIGN KEY (InventoryID)
REFERENCES Inventory(InventoryID),
CONSTRAINT fk_Rnt_Rate FOREIGN KEY (RateID)
REFERENCES Rates(RateID),
CONSTRAINT fk_Rnt_Cus FOREIGN KEY (CustomerID)
REFERENCES Customers(CustomerID)
);
–Rentals–
INSERT INTO Rentals(RentalID, InventoryID, RateID, DateRented, ReturnDate, CustomerID)
VALUES(401, 1, 301, TO_DATE(‘2018/04/20’, ‘yyyy/mm/dd’), TO_DATE(‘2018/04/30’, ‘yyyy/mm/dd’), 101);
SQL>
SQL> SELECT * FROM Rentals
WHERE DateRented > SYSDATE – 30
ORDER BY DateRented; 2 3
no rows selected