Question

CUSTOMER EMP INVOICE LINE P CODE V CODE CUS CODE EMP CODE NV NUMBER NV NUMBER, LINE NUMBER Create SQL queries for displaying the following results 5. List the customers who have ordered product bearing product code 23109-HB. Display first names, last names of customers, invoice numbers and product codes 6. Display Vendor details (V_CODE, V NAME) and product details (P CODE, P DESCRIPT) and product quantity on hand in excess of product min quantity (give alias of Quantity above Minimum) for products where Quantity above Minimum is less than 10 items. Sort result in the ascending order of Quantity above Minimum . For each product invoiced on 01-16-2010 display the product details (P CODE, P DESCRIPT),invoice date and the total number of items sold (give suitable column title) along with the total amount of sales (give suitable column title and sort the results on this field) There should be one row displayed per Product 8. For each vendor based in Tennessee (TN) display the Vendor details (V CODE, V NAME, V STATE) and the total number of items sold (give suitable column title) along with the total amount of sales (give suitable column title and sort the results on this field). There should be one row displayed per Vendor 9 Who are the customers with no invoices placed. Display last name, first name, customer balance for these 10. Display first and last name(s) of customers who have bought the product with the highest price? in Submission Requirements You will upload word file to the Moodle by the due date and time that shows the screenshots of each query followed by the result. Above each query, please write your full name as a comment. Also, write your name, course number, and the semester name on the coversheet Make sure that you increase the size of the T-SQL results section at the bottom of Visual Studios SQLQuery window to show all rows of your result set as some queries display several rows Solve the problems in the order in which they are listed in the assignment. Indicate the question number before each query TABLE P P DESCRIPT P.INDATE P.QOH P MIN P PRICE P DISCOUNT V CODE P MIN ORDER P REORDER QER/31 Power painter, 15ps3nozzle 2009-11-03 00:00 00 000 8 3-02/P2725n pwr saw blade 4013 9.00n pr saw biade 546-002 Hrd. coth, 1/44n 250 2009-12-13 00 0000 000 32 2005-11-13 000000 .000 18 2010-01-15 00 0000 .000 15 2010-01-15 000000 .000 23 009-12-30 00 0000 000 009-12-24 00 00 00 000 2010-01-20 00:00.00.000 125 2010-01-20 000000.000 2 2010-01-02 00 00 00.000 009-12-15 00 00 00 .000 43204 000 2010-02-07 00 00100 0001 2010-02-20 00 0000 000 188 75 58 2010-03-01 0000 00 000 17275699000 2010-02-24 00 0000 000 237 100 845 0999 0.00 1499 005 749 000 995 0.00 43.99 000 09 92 005 9987 005 895 005 10 995 010 1440 005 25595 25 134450 1344 50 3119 35 23119 25 24288 15 24288 15 25595 12 21225 25 NULL 12 21344 25 24288 10 NULL 50 21225 50 21231 100 25595 10 15 232/QTY BADw, 12in blade 3109-HB Clew hammer 3114AA Slede hanmer, 12 S-WREQ Hiout chain saw, 16 in M-18277125n metal sorew,25 25699 005 W 23116 25nd screw, 50 WR3/TT3 Steelmatting, 4xBx1/652010-01-17 00:00 00 00018 995 0.10TABLE V CODE V NAME 21225 Bryson, Inc 21226 SuperLoo, Inc. Rlushing 23 D&E Supply 21344 Gomez Bros 22567 Dome Supply Smith 23119 Randsets Ltd 24004 Brackman Bros. Browning 615 24288 ORDVA, Inc. 25443 B&K, Inc. 25501 Damal Supplies Smythe 25595 Rubicon Systems Orton V CONTACT V AREACODE V PHONE V STATE V ORDER 223-3234 TN 215-8995 FL 228-3245 TN 889-2546 KY 678-1419 GA 678-3998 GA 228-1410TN 98-1234 TN 227-0093 FL 890-3529 TN 456-0092 FL 901 Anderson 901 TABLE INVOICE NV NUMBER CUS CODE INV DATE 1001 1002 1003 1004 1005 1006 1007 0014 10011 10012 10011 10018 10014 10015 2010-01-16 00:00:00.000 2010-01-16 00:00:00.000 2010-01-16 00:00:00.000 2010-01-17 00:00:00.000 2010-01-17 00:00:00.000 2010-01-17 00:00:00.000 2010-01-17 00:00:00.000 TABLE LINE INV NUMBER LINE NUMBER P CODE 1001 1001 1002 1003 1003 1003 1004 1004 1005 1006 1006 1006 1006 1007 1007 1008 1008 1008 LINE UNITS LINE_PRICE 3Q2/P2 1.00 3109-HB 1.00 54778-2T 2.00 2238/QPD 1.00 1546Q02 1.00 3-Q2/P2 5.00 4778-2T 3.00 23109-HB 200 PVC23DRT 12.00 SM-182773.00 2232/QTY 1.00 23109-HB 1.00 89-WREQ 1.00 3Q2/P2 200 4778-2T 1.00 PVC23DRT 5.00 WR3/TT3 3.00 23109-HB 1.00 14.99 38.95 39.95 109.92 256.99 4.99 119.95TABLE EMP EMP NUM EMP TITLE EMP LNAME EMP FNAME EMP INITIAL EMP DO8 EMP HIRE TE EMP AREACODE EMP PHONE EMP_MGR Kolmycz George 1942-06-15 0000 00.000 1985-03-15 00 00:00 000 61 1965-03-19 0000 00.000 1986 04-25 00:0000 000 615 958-11-14 00-00 00.000 1990-12-20 00 00 00 000 901 974-10-16 00 00 00.000 199408 28 00 00 00 000 615 1971-11-08 00 00 00 000 1994 1020 00-00-00 000 901 19750314000000000 1996-11-08000000… 615 968-02-12 00 00:00.000 1989 01-05 0000 00.000 615 974-08-21 00 00 00.000 1994-07-02 00 00:00 000 615 1966-02-14 00-00-00.000 1992-11-18 00 00 00 000 615 1961-06-18 00-0000.000 198904-14 00-00 00 000 901 970-05-19 00 00.00.000 1990-12-01 00 00:00.000 90 1966-01-03 0000.00.000 1993-06-21 00 00:00.000 615 1961-05-14 000000000 1983-12-01 000000000 615 970-09-15 00 00.00.000 1999-05-11 00:00:00.000 15 956-11-02 00 00.00.000 1979-11-15 00 00:00.000 90 1972-07-25 0000.00.000 1953-04-23 00 0000.000 615 1965-11-08 00 00.00.000 1988-12-10 00:00.00.000 615 24-4472 75-8993 98-3456 100 100 NULL 90-3220NULL 324-7883 Weserbach Pau 504-3335 110 690093108 Washington Rupert 112 113 114 115 116 249006 105 82-0845 108 890-2984 108 Table CUSTOMER CUS CODE CUS_LNAME CUS FNAME CUS INITIAL CUS AREACODE CUS PHONE CUS BALANCE 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 615 713 615 44-2573 894-1238 894-2285 894-2180 222-1672 442-3381 297-1228 290-2556 382-7185 297-3809 0.00 0.00 45.86 536.75 0.00 0.00 221.19 768.93 216.55 0.00 Paul NULL 615 713 OBrian NULL Williams Fariss 713 615

0 0
Add a comment Improve this question Transcribed image text
Answer #1

5. SELECT c.CUS_LNAME, c.CUS_FNAME, i.INV_NUMBER, l.P_CODE FROM CUSTOMER c, INVOICE i, LINE l WHERE c.CUS_CODE = i.CUS_CODE AND i.INV_NUMBER, l.INV_NUMBER AND i.P_CODE = '23109-HB';

6. SELECT v.V_CODE, v.V_NAME, p.P_CODE, p.P_DESCRIPT, (p.QOH-p.MIN) AS 'Quantity over Minimum' FROM PRODUCT p, VENDOR v WHERE p.V_CODE = v.V_CODE AND (p.QOH-p.MIN) < 10 ORDER BY (p.QOH-p.MIN);

7. SELECT v.V_CODE, v.V_NAME, v.V_STATE, i.INV_DATE, sum(l.LINE_UNITS) AS TotalItemsSold, sum(l.LINE_UNITS*l.LINE_PRICE) AS TotalSalesAmount FROM PRODUCT p, INVOICE i, LINE l WHERE p.P_CODE = l.P_CODE AND l.INV_NUMBER = i.INV_NUMBER AND i.INV_DATE = '01-16-2010 GROUP BY l.P_CODE ORDER BY TotalSalesAmount;

8. SELECT p.P_CODE, p.P_DESCRIPT, sum(l.LINE_UNITS) AS TotalItemsSold, sum(l.LINE_UNITS*l.LINE_PRICE) AS TotalSalesAmount FROM PRODUCT p, VENDOR v, INVOICE i, LINE l WHERE p.P_CODE = l.P_CODE AND l.INV_NUMBER = i.INV_NUMBER AND p.V_CODE = v.V_CODE AND v.V_STATE = 'TN' GROUP BY p.V_CODE ORDER BY TotalSalesAmount;

NOTE: As per Chegg policy, I am allowed to answer only 4 questions (including sub-parts) on a single post. Kindly post the remaining questions separately and I will try to answer them. Sorry for the inconvenience caused.

Add a comment
Know the answer?
Add Answer to:
CUSTOMER EMP INVOICE LINE P CODE V CODE CUS CODE EMP CODE NV NUMBER NV NUMBER,...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using the ch08_saleco database write a T-SQL query to display the customer code, invoice number invoice...

    Using the ch08_saleco database write a T-SQL query to display the customer code, invoice number invoice date, and invoice subtotal from invoice conditioned on the invoice subtotal is greater than $100 and from only customer codes 10011 and 10012. (hint: in) /* Database Systems, 8th Ed., Rob/Coronel */ /* Type of SQL : SQL Server */ CREATE TABLE CUSTOMER ( CUS_CODE int, CUS_LNAME varchar(15), CUS_FNAME varchar(15), CUS_INITIAL varchar(1), CUS_AREACODE varchar(3), CUS_PHONE varchar(8), CUS_BALANCE float(8) ); INSERT INTO CUSTOMER VALUES('10010','Ramas','Alfred','A','615','844-2573','0'); INSERT...

  • Create SQL statements based on the given tables: Code to create the tables: CREATE DATABASE LAB...

    Create SQL statements based on the given tables: Code to create the tables: CREATE DATABASE LAB4DB; USE LAB4DB; CREATE TABLE CUSTOMER ( CUS_CODE int primary key, CUS_LNAME varchar(15), CUS_FNAME varchar(15), CUS_INITIAL varchar(1), CUS_AREACODE varchar(3), CUS_PHONE varchar(8), CUS_BALANCE float(8) ); INSERT INTO CUSTOMER VALUES('10010','Ramas','Alfred','A','615','844-2573','0'); INSERT INTO CUSTOMER VALUES('10011','Dunne','Leona','K','713','894-1238','0'); INSERT INTO CUSTOMER VALUES('10012','Smith','Kathy','W','615','894-2285','345.86'); INSERT INTO CUSTOMER VALUES('10013','Olowski','Paul','F','615','894-2180','536.75'); INSERT INTO CUSTOMER VALUES('10014','Orlando','Myron','','615','222-1672','0'); INSERT INTO CUSTOMER VALUES('10015','O''Brian','Amy','B','713','442-3381','0'); INSERT INTO CUSTOMER VALUES('10016','Brown','James','G','615','297-1228','221.19'); INSERT INTO CUSTOMER VALUES('10017','Williams','George','','615','290-2556','768.93'); INSERT INTO CUSTOMER VALUES('10018','Farriss','Anne','G','713','382-7185','216.55'); INSERT INTO CUSTOMER VALUES('10019','Smith','Olette','K','615','297-3809','0'); /*...

  • All the required files are attached to this question here in the form of images. Please refer the attached images and answer the questions. List the names and codes of vendors and the number of produ...

    All the required files are attached to this question here in the form of images. Please refer the attached images and answer the questions. List the names and codes of vendors and the number of products each vendor has supplied, i.e. vendor AA has supplied xxx products, and vendor BB has supplied yyy products etc. Show the total value of invoices for each customer with the customer the Last Name, and a column heading showing ‘Total_invoice_value’ in the results. List...

  • Question 1. For each table, identify the primary key and the foreign key(s). If a table...

    Question 1. For each table, identify the primary key and the foreign key(s). If a table does not have a foreign key, write None. Question 2. Do the tables exhibit entity integrity? Answer yes or no, and then explain your answer. Question 3. Do the tables exhibit referential integrity? Answer yes or no, and then explain your answer. Write NA (Not Applicable) if the table does not have a foreign key. Question 4. Describe the type(s) of relationship(s) between CUSTOMER...

  • Create a stored procedure named prc_inv_amounts to update the INV_SUBTOTAL, INV_TAX, and INV_TOTAL. The procedure takes the invoice number as a parameter. The INV_SUBTOTAL is the sum of the LINE_TOTAL...

    Create a stored procedure named prc_inv_amounts to update the INV_SUBTOTAL, INV_TAX, and INV_TOTAL. The procedure takes the invoice number as a parameter. The INV_SUBTOTAL is the sum of the LINE_TOTAL amounts for the invoice, the INV_TAX is the product of the INV_SUBTOTAL and the tax rate (8 percent), and the INV_TOTAL is the sum of the INV_SUBTOTAL and the INV_TAX /* Database Systems, Coronel/Morris */ /* Type of SQL : SQL Server */ /* WARNING: */ /* WE HIGHLY RECOMEND...

  • * myCompany.SQL Introduction to SQL Script file for ORACLE DBMS This script file creates the following...

    * myCompany.SQL Introduction to SQL Script file for ORACLE DBMS This script file creates the following tables: VENDOR, PRODUCT, CUSTOMER, INVOICE, LINE EMPLOYEE and loads the default data rows */ set echo on; set serveroutput on; select systimestamp from dual; show user; ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY'; DROP TABLE LINE CASCADE CONSTRAINTS; DROP TABLE INVOICE CASCADE CONSTRAINTS; DROP TABLE CUSTOMER CASCADE CONSTRAINTS; DROP TABLE PRODUCT CASCADE CONSTRAINTS; DROP TABLE VENDOR CASCADE CONSTRAINTS; DROP TABLE EMPLOYEE CASCADE CONSTRAINTS; CREATE TABLE...

  • Present Value of : SI Revival Paid On l'uint in Time Print Value of Series of...

    Present Value of : SI Revival Paid On l'uint in Time Print Value of Series of qual Paymenis (Army) over Time 1 Kallangany is considerine an interent that is an outy 2016 au: SOL.023 oli ilu w Ch ow Thucy's Colapital Freets Requel Preservat Forma P-1-1/2'IN Couple NPV ulleres meul. E--- i N N N N 12 R 1 6 3 03 05 06 07 08 09 053 05158 OSIN 0.9791 292 089978850 WE 28686 2 0360 0900343 098 0.900...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT