There are two tables: clients and contacts. Clients is linked to Contacts by Con
ID: 3798772 • Letter: T
Question
There are two tables: clients and contacts. Clients is linked to Contacts by ContactID. Clients has additional information available in it that may not be available in Contacts. You know that all Clients are Contacts but not all Contacts are Clients. The structure of the tables is below.
Contacts Clients
ContactID* ClientID
ContactName ContactID
ContactAddress Billable (T/F)
Email PastDueAmount (float)
Phone
ContactType
You have been tasked with finding the names, addresses, and emails for billable clients with a past due bill. Create the SQL to retrieve the data from the tables.
Explanation / Answer
query is simple, just check billabiltity and pastdueamount and join it with contacts table with contact id to get requeried information.
coalesce function will check the field is null , if null then it will replace it with 0.00. this will help us to validate both null and 0 values.
query:
select b.contactname ,b.contactaddress,b.email
from clients a inner join contacts b on a.contactid =b.contactid
where a.billable ='T' and coalesce(a.pastdueamount,0.00) <>0.00
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.