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

Write an SQL query that will output the employee id, first name and hire date from...
Write an SQL query that will output the employee id, first name and hire date from the employee table. Pick only those employees whose employee ID is specified in the employee table (no nulls). If the employee id is 777, name is ABC and hire date is 01-JAN-2016, the output should be like - ' ABC (Employee ID - 777) was hired on 1, January of 2016'. Note - The date should not have preceding zeros.
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...
In sql: Write a query to produce a listing of unique vendor names who have at...
In sql: Write a query to produce a listing of unique vendor names who have at least one invoice with us. You are using a table view called COMPANY_INFORMATION that lists a vendor id, vendor name, term id, and term description. The second table you will reference is the invoice table that lists vendor id, invoice num, invoice number, and invoice total. Do not show duplicate results.
IN MY SQL: - Display each Author’s ID, first and last names and the total number...
IN MY SQL: - Display each Author’s ID, first and last names and the total number of pages for all of the Books they have written. - Display each Book genre as well as the number of Books written in that genre with the column header “Number Of Books” - Display the Author’s first and last name, as well as their ID, and the Book title and number of pages for all of the books they have written that have...
using Access show step by step how to create a table for ID (data type number...
using Access show step by step how to create a table for ID (data type number and field size 10) and discount (data type number where 1=5% and 2=10%) one table with two fields (id and discount)
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.
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"
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.
Write a query that returns the department id and the number of employees (in the associated...
Write a query that returns the department id and the number of employees (in the associated department) salary is over $2500 and, at the end, result page has to show only department ids that have more than 5 employees in it. Please Note: (we don't interest all of department ids in our grouping action and also we don’t want to see any kind of total employee number in the result page we want to see limited result set) Hint1: SELECT...
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)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT