This advanced SQL exercise is part of the book: Advanced SQL – Practical Techniques and Use-Cases, which includes 100 day-to-day SQL challenges (and solutions), need-to-know advanced features, and key concepts.
Given a table that specifies invoices issued to different customers. For example, you can see that invoice no.1, which was issued on January 15th, totals 350 ILS, and its payment due date is no later than February 3rd. In addition, it is given that the maximal difference between the invoice issue date and the payment due date is 30 days.
CREATE TABLE Invoices (invoiceID int identity(1,1), invoiceAmount int, sdate date, edate date) GO