Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions