Question

In: Computer Science

Step 1: Write SQL to List the information delivered (PO number, order date, vendor ID &...

Step 1: Write SQL to List the information delivered (PO number, order date, vendor ID & name, product ID & name, Product quantity) of transaction records, sorted by order date?

Step 2: Write SQL For orders that were placed between 9/1/2016 and 9/30/2016, list (product IDs, product names, order dates, PO numbers) sort by order date

Step 3: Write SQL and find

In the month of August, which vendor received the smallest order for a product in terms of dollars?

Hint the date returned should have these headings:

vendor_id, vendor_name, order_date, po_number, line_number, Product_ID, total_cost

Solutions

Expert Solution

ANSWERS -

(NOTE : Product name, Product quantity column name is not specified so taking a random name as Product_Name, Product_Quantity . If you have the details pls put in a comment, I will update the answer asap)

STEP 1 : To list all the details of the delivered product from the transaction record in a sorted table with respect to the order date. We use here ORDER BY clause to retrieve a sorted list.

Table Name - transaction

Column Names - po_number, order_date, vendor_id, vendor_name, Product_ID, Product_Name, Product_Quantity

The query to form is,

SELECT po_number, order_date, vendor_id, vendor_name, Product_ID, Product_Name, Product_Quantity FROM transaction ORDER BY order_date ;

The resultant output will be,

po_number order_date vendor_id vendor_name Product_ID Product_Name Product_Quantity

The output will list the details in sorted order.

STEP 2 : To list the orders that were placed between certain dates , we use WHERE condition along with BETWEEN operator and ORDER BY to sort.

Table name - orders

Column name - Product_ID, Product_Name, order_date, po_number

The query to form is,

SELECT Product_ID, Product_Name, order_date, po_number FROM orders WHERE order_date BETWEEN '2016/9/1' AND '2016/9/30' ORDER BY order_date ;

This will give the sorted output of order details which were placed between the dates.

Product_ID Product_Name order_date po_number

Step 3 : To list the details of vendor who has smallest order for product in the month of august. We use here MIN function to retrieve the smallest order and WHERE condition.

Table name - product

Column name - total_cost

The query to form is,

SELECT vendor_id, vendor_name, total_cost FROM product WHERE total_cost = ( SELECT MIN(total_cost) FROM product WHERE MONTH(order_date)= 8) ;

This will give the output,

vendor_id vendor_name total_cost

This will list the output of vendor who has smallest order done in month of august.

=================================END================================

Please comment if u need any other info and DO LEAVE A LIKE, it would mean a lot. Thanks :)


Related Solutions

1. Write the SQL code required to list the employee number, first and last name, middle...
1. Write the SQL code required to list the employee number, first and last name, middle initial, and the hire date. Sort your selection by the hire date, to display the newly hired employees first. 2. Modify the previous query and list the employee first, last name and middle initial as one column with the title EMP_NAME. Make sure the names are listed in the following format: First name, space, initial, space, last name (e.g. John T Doe). Hint: use...
write a sql statement that retrieves product ID (ProductID) and name (Name) from Production.product table for...
write a sql statement that retrieves product ID (ProductID) and name (Name) from Production.product table for all product whose name includes both the words "silver" and "frame"
a) Write C code using a struct to hold student information: integer id integer number of...
a) Write C code using a struct to hold student information: integer id integer number of hours taken integer number of hours passed double gpa b) create a variable of the type in #25 and initialize it with some data.
An e-retailing company assigns an ID to online orders received. Order ID starts with 3-digit number,...
An e-retailing company assigns an ID to online orders received. Order ID starts with 3-digit number, followed by four letters of alphabet. a) How many unique order IDs could be generated? b) What is the probability that first order is assigned an ID where sum of 3 digits equals 4? For instance, consider order ID “123 ABCD” with sum of three digits equals 1+2+3 = 6.
Homework: Populate Sales Order tables. Write SQL to : 1. insert 5 records in each table:...
Homework: Populate Sales Order tables. Write SQL to : 1. insert 5 records in each table: Market, Region, ProductFamily, Manager (all Managers must have different % commissions, Commission is an attribute of the Manger). 2. Insert 5 records in Agent using all Managers 3. Insert 15 records in Product using  all ProductFamily 4. Insert 15 records in Customer using various Regions and Markets 5. Insert 50 records in SalesOrder using various Customers, Products, Agents Notes : ALL the Names ( Description)...
Write SQL queries below for each of the following: List the names and cities of all...
Write SQL queries below for each of the following: List the names and cities of all customers List the different states the vendors come from (unique values only, no duplicates) Find the number of customers in California List product names and category descriptions for all products supplied by vendor Proformance List names of all employees who have sold to customer Rachel Patterson
Write and run the SQL to list the different expected graduation dates [class of 20XX] in...
Write and run the SQL to list the different expected graduation dates [class of 20XX] in the BSU_Students table. List each expected graduation date only once.  
The client’s medication list includes: 1) donepezil (Aricept) 5 mg PO daily 2) Sinemet 10/100 PO...
The client’s medication list includes: 1) donepezil (Aricept) 5 mg PO daily 2) Sinemet 10/100 PO TID 3) aspirin 325 mg PO daily 4) warfarin (Coumadin) 5 mg PO qHS 5) tolterodine (Detrol) 2 mg PO BID 6) atorvastatin (Lipitor) 40 mg PO qHS 7) insulin (long-acting and sliding scale) 8) gabapentin (Neurontin) 300 mg PO TID 9) iron sulfate 325 mg PO TID 10) trazodone 50 mg PO qHS 11) levothyroxine 50 mcg PO daily 12) furosemide (Lasix) 60...
The following are all the steps in the accounting cycle. Number each step in the order...
The following are all the steps in the accounting cycle. Number each step in the order in which they should be done. Please write your answer in the space provided. - Closing entries are journalized and posted to the ledger. - An unadjusted trial balance is prepared. - An optional end-of-period spreadsheet (work sheet) is prepared. - A post-closing trial balance is prepared. - Adjusting entries are journalized and posted to the ledger. - Transactions are analyzed and recorded in...
Write the following SQL queries and show the corresponding output of the DBMS: 1) Write an...
Write the following SQL queries and show the corresponding output of the DBMS: 1) Write an SQL statement to display all the information of all Nobel Laureate winners. 2) Write an SQL statement to display the string "Hello, World!". 3) Write an SQL query to display the result of the following expression: 2 * 14 +76. 4) Write an SQL statement to display the winner and category of all Laureate winners. 5) Write an SQL query to find the winner(s)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT