Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help with these SQL question using the AP Database /*=========================================================================================== Q1 (7 rows): Write a query that returns the InvoiceNumber and the days from

Please help with these SQL question using the AP Database /*=========================================================================================== Q1 (7 rows): Write a query that returns the InvoiceNumber and the days from the invoice date to the payment date (named DaysPassed) as long as it is 40 or more days. Order the list by the DaysPassed from highest to lowest. Actual output below:

InvoiceNumber DaysPassed 77290 52 75C-90227 49 121897 44 RTR-72-3662-X 44 24946731 40 109596 40 25022117 40

*/

/*=========================================================================================== Q2 (10 rows): Write a query that returns a list of the states that have invoices. Return the state only and order by the state ( No join statements allowed. Use a sub-query ). Actual output below:

VendorState AZ CA DC MA MI NV OH PA TN TX */

/*=========================================================================================== Q3 (5 rows): Write a query that returns the top 5 vendors with the highest total invoices (i.e., all invoices summed up). Return the VendorID, TotalInvoices, and the InvoiceCount. Actual output below:

VendorID TotalInvoices InvoiceCount 110 119892.41 5 122 23177.96 9 72 21927.31 2 104 7125.34 1 99 6940.25 1 */

/*=========================================================================================== Q4 (2 rows): Write a query that will return a list of Vendors that have: > An 800 number > The first number of their zipcode is from 1 to 5 > The second number of their zipcode is from 3 to 5 > The last number of their zipcode is a 5

Include columns: VendorName, VendorPhone, and VendorZipCode Actual output below:

VendorName VendorPhone VendorZipCode Publishers Weekly (800) 555-1669 43305 Champion Printing Company (800) 555-1957 45225 */

/*=========================================================================================== Q5 (44 rows): Write a query that returns all vendors that have a PO Box. Note, there are many forms that are listed (e.g., PO Box, P O Box, P.O. Box, etc.) so you should only look for Box. > Exclude all records that do not have a phone number. > Return VendorName, VendorAddress1, VendorAddress2, and VendorPhone. > Do not show NULLs for any of the fields. You should account for NULLS being in VendorAddress1 and VendorAddress2 > Sort the list by VendorName

First 5 rows listed below:

VendorName VendorAddress1 VendorAddress2 VendorPhone American Express Box 0001 (800) 555-3344 BFI Industries PO Box 9369 (559) 555-1551 Blue Cross PO Box 9061 (800) 555-0912 Blue Shield of California PO Box 7021 (415) 555-5103 Cahners Publishing Company Citibank Lock Box 4026 8725 W Sahara Zone 1127 (301) 555-2162 */

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

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

Ty e2y Evaluate the integral dy

Answered: 1 week ago

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago