Question

Write a select query to return the 'InvoiceID' and a field called 'Status' from the invoices...

Write a select query to return the 'InvoiceID' and a field called 'Status' from the invoices table. The status field is either 'Late' or 'Paid' or 'Pending'. The status field will be 'Late' if the InvoiceDueDate is BEFORE 2016-04-30. The status field will be 'Paid' if there is a value in the PaymentDate field. Lastly, if the invoice isn't late or paid, the status will be 'Pending'. Do not sort the results.

Homework Answers

Answer #1

If Status field is given in the table -

SELECT InvoiceID, Status FROM invoices;

If Status field is not given in the table -

SELECT InvoiceID,

CASE

WHEN InvoiceDueData <= '2016-04-30' THEN "Late"

WHEN PaymentDate != NULL THEN "Paid"

ELSE "Pending"

END AS Status

FROM invoices;

The solution was easy if the status field is given in the table but when it's not given in the field, The switch case is needed and accordingly compared with the required values given in the question.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Class-In Assignment 3: Chapters 4&5 How to retrieve data from two or more tables Exercises 1....
Class-In Assignment 3: Chapters 4&5 How to retrieve data from two or more tables Exercises 1. Write a SELECT statement that returns all columns from the Vendors table inner-joined with all columns from the Invoices table. 2. Write a SELECT statement that returns four columns: vendor_name vendor_name from the Vendors table invoice_number invoice_number from the Invoices table invoice_date invoice_date from the Invoices table balance_due invoice_total minus payment_total minus credit_total from the Invoices table The result set should have one row...
Write an aggregate called selectivesum that sums the values of numbers in a column, but only...
Write an aggregate called selectivesum that sums the values of numbers in a column, but only if the value is present in the table t . E.g., suppose t contains the values 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Suppose that table m has a column y of type integer. Here is the table M Psuedocode for the sfunc function:The result of the query SELECT selectivesum(y) FROM m; is 7. step(x, y) if(y is in t) return...
EMPLOYEE Field Name EMP_ID EMP_LNAME EMP_MI EMP_FNAME EMP_SEX EMP_AGE EMP_SALARY EMP_HIREDATE DEPT_CODE Table: DEPARTMENT DEPT_CODE BIOL...
EMPLOYEE Field Name EMP_ID EMP_LNAME EMP_MI EMP_FNAME EMP_SEX EMP_AGE EMP_SALARY EMP_HIREDATE DEPT_CODE Table: DEPARTMENT DEPT_CODE BIOL CPTR HIST MATH RELB Data Type Text Text Text Text Text Number Currency Date/Time Text DEPT_TITLE Biology Computer Science History Mathematics Religion    Field Name DEPT_CODE DEPT_TITLE Data Type Text Text INSTRUCTIONS Use SQL commands to create the tables and enter the data shown above using MS Access. Write the following SQL statement given below: 1. 2. 3. 4. 5. 6. 7. 8. 9....
Objective: Write a Java program that will use a JComboBox from which the user will select...
Objective: Write a Java program that will use a JComboBox from which the user will select to convert a temperature from either Celsius to Fahrenheit, or Fahrenheit to Celsius. The user will enter a temperature in a text field from which the conversion calculation will be made. The converted temperature will be displayed in an uneditable text field with an appropriate label. Specifications Structure your file name and class name on the following pattern: The first three letters of your...
** Note ** Execute the following query before completing steps 1 and 2: INSERT INTO Employees...
** Note ** Execute the following query before completing steps 1 and 2: INSERT INTO Employees (LastName, FirstName, BirthDate, Notes) VALUES ('Smith','Mary','1980-10-15','John is a student at Nashville State.'); 1. Using the record you just created in the Note above, write a query to update the LastName field to Jones. 2. Using the record you just created in the Note above, write a query to delete that record. 3. Write a query using the Products table that will return the sum...
Summary The Ch08_ConstructCo database stores data for a consulting company that tracks all charges to projects....
Summary The Ch08_ConstructCo database stores data for a consulting company that tracks all charges to projects. The charges are based on the hours each employee works on each project. The structure and contents of the Ch08_ConstructCo database are shown in Figure P8.1. Use this database to answer the following problems. Database Schema The schema for the Ch08_ConstructCo database is shown below and should be used to answer the next several problems. Click this image to view it in its own...
Write a Python 3 program called “parse.py” using the template for a Python program that we...
Write a Python 3 program called “parse.py” using the template for a Python program that we covered in this module. Note: Use this mod7.txt input file. Name your output file “output.txt”. Build your program using a main function and at least one other function. Give your input and output file names as command line arguments. Your program will read the input file, and will output the following information to the output file as well as printing it to the screen:...
1. A random number generator is used to select a number from 1 to 500 ?(inclusively)....
1. A random number generator is used to select a number from 1 to 500 ?(inclusively). What is the probability of selecting the number 595 ? What is the probability? 2.Identify the sample space of the probability experiment and determine the number of outcomes in the sample space. -Randomly choosing an even number between 10 and 20, inclusive The sample space is? (Use a comma to separate answers) There are _____ outcomes in the sample space 3. Determine the number...
Please analyze, from the perspective of finance, the choice of buying a house vs renting an...
Please analyze, from the perspective of finance, the choice of buying a house vs renting an apartment. To make a quantitative analysis, suppose you have collected the following information: If you rent a 1,000 sq ft two-bedroom apartment in RTP area, your monthly rent will be $900. The apartment is in move-in condition. You won’t have any upfront expenses when you move in. If you want to buy a house, a 2,000 sq ft three-bedroom townhouse in RTP area is...
I have solved the problem up to number 6. all my answers from 7 keeps coming...
I have solved the problem up to number 6. all my answers from 7 keeps coming up incorrect. That is where i need the help. Thank you Note: This problem is for the 2018 tax year. Daniel B. Butler and Freida C. Butler, husband and wife, file a joint return. The Butlers live at 625 Oak Street in Corbin, KY 40701. Dan's Social Security number is 111-11-1112, and Freida's is 123-45-6789. Dan was born on January 15, 1967, and Freida...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT