Question: Challenging question try your best 7. Write a SELECT statement that determines whether the PaymentDate column of the Invoices table has any invalid values. To

Challenging question try your best

7. Write a SELECT statement that determines whether the PaymentDate column of the Invoices table has any invalid values. To be valid, PaymentDate must be a null value if theres a balance due and a non-null value if theres no balance due. Code a compound condition in the WHERE clause that tests for these conditions. See hint below.

Hint for #7 - This statement is a little tricky. You are looking for invalid records. The easiest way to figure this out is to check for valid conditions and then reverse. You are checking for 2 conditions 1. PaymentDate must be a null value if theres a balance due and 2. a non-null value if theres no balance due

You need to check BalanceDue, which needs to be calculated (InvoiceTotal - PaymentTotal - CreditTotal)

To be valid, PaymentDate must be a null value, if theres a balance due. First write the valid condition (PaymentDate is null and BalanceDue > 0) you are looking for invalid values so you need to reverse the check for PaymentDate like this (PaymentDate is not null and BalanceDue > 0)

AND

Second valid condition, a non-null value if theres no balance due.

Again write valid condition (PaymentDate Is Not Null and if BalanceDue <= 0) you are looking for invalid values so you need to reverse it (PaymentDate Is Null and BalanceDue <= 0)

Code a compound condition in the WHERE clause that tests for either of these conditions.

Dont forget BalanceDue needs to be calculated.

This question is asking you to check for invalid values just keep in mind there may not be any.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!