Question: SQL CODING QUESTION: THERE ARE TWO TABLES IN THIS PROJECT, each with the common column of vendorid. the table names are: SALES, and VENDOR the

SQL CODING QUESTION:

THERE ARE TWO TABLES IN THIS PROJECT, each with the common column of vendorid.

the table names are: SALES, and VENDOR

the columns of the SALES table are as follow: STORE, UPC, WEEK, MOVE, QTY, PRICE, SALE, PROFIT, OK, YEAR, VENDORID

the columns of the VENDOR table are as follows: VENDORID, NAME, ADDRESS, STATE, UPC, BALANCE, CREATEDATE, CLOSEDATE

THIS ARE THE QUERIES I NEED, I KNOW THEY ARE RELATIVELY SIMPLE AND BUILD OFF EACH OTHER. THANKS SO MUCH IN ADVANCE

Query 4: Return the vendor id, vendor name, product UPC code, move, and sales (price * move/qty) for each product sold by store 100 in 1995. Sort by sales descending. N.B since year is a reserved word in SQL, you will need to surround the field year in quotes in order for it to work.

Query 5: Return the total sales (this is not a column in either table) (price*move/qty) for each product. The output should have the UPC of a product and the total sales of that product. Call the new field totalSales.

Query 6: Return only the total sales (this is not a column in either table) (price*move/qty) for each product that exceed $40,000. Again, the output should have the UPC of a product, the total sales of that product and have the calculated field renamed as totalSales.

Query 7: For each vendor return the total sales of their products at each store between the years 1992 and 1995 (inclusive). Sort by total sales descending. The output should have the vendor name, store number, and total sales (renamed as totalSales).

Query 8: For each store and product, return the totalSales, total gross profit (both of which are not columns in either table) (totalGP = price*move/qty*profit/100), count of weekly sales records, and average move amount of the product at that store. Only show data for vendors with a name > 'H'. Sort by gross profit descending. The output should have the store number, product UPC, total sales, total gross profit, count of records, and average move volume (renamed averageMove).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!