Question

In: Computer Science

Table product P_CODE P_DESCRIPT P_INDATE P_QOH P_MIN P_PRICE P_DISCOUNT V_CODE 23114-AA Sledge hammer, 12 lb. 02-01-08...

Table product

P_CODE P_DESCRIPT P_INDATE P_QOH P_MIN P_PRICE P_DISCOUNT V_CODE
23114-AA Sledge hammer, 12 lb. 02-01-08 8 5 14.4 0.05
54778-2T Rat-tail file, 1/8-in. fine 15-12-07 43 20 4.99 0 21344
89-WRE-Q Hicut chain saw, 16 in. 07-02-08 11 5 256.99 0.05 24288

and so on.....

Table vendor

V_CODE V_NAME V_CONTACT V_AREACODE V_PHONE V_STATE V_ORDER
21225 Bryson, Inc. Smithson 615 223-3234 TN Y
21226 SuperLoo, Inc. Flushing 904 215-8995 FL N
21231 D&E Supply Singh 615 228-3245 TN Y
21344 Gomez Bros. Ortega 615 889-2546 KY N

And so on.....

write a query to get

Using EXCEPT show the codes of the vendors who did not supply any products.

Solutions

Expert Solution

Solution:

Here 2 tables are given. product table and vendor table. some vendor supplies some products and some are not supplying anything.

EXCEPT is SQL clause. When using EXCEPT clause, there are 2 SELECT statements and they are joined using EXCEPT clause

Query to get the display the codes of the vendors who did not supply any products using EXCEPT clause:

SELECT V_CODE
FROM vendor
EXCEPT
SELECT V_CODE
FROM product;

The vendor codes returned by SELECT statement for product table are removed from the records returned by the SELECT statement for vendor table.

PLEASE SEE THE DATA USED IN INSERT QUERY. NOTICE V_CODE 21225 IS THE ONLY VENDOR WHICH SUPPLIES ANY PRODUCT.

SQL QUERY AND DATA USED:

/* Create a table called NAMES */
CREATE TABLE product(
P_CODE VARCHAR(30) PRIMARY KEY,
P_DESCRIPT TEXT,
P_INDATE DATE,
P_QOH INTEGER,
P_MIN INTEGER,
P_PRICE FLOAT,
P_DISCOUNT FLOAT,
V_CODE INTEGER);

/* Create few records in this table */
INSERT INTO product VALUES("23114-AA","Sledge hammer, 12 lb.","02-01-08",8,5,14.4,0.05,NULL);
INSERT INTO product VALUES("54778-2T","Rat-tail file, 1/8-in. fine","15-12-07",43,20,4.99,0,21344);
INSERT INTO product VALUES("89-WRE-Q","Hicut chain saw, 16 in.","07-02-08",11,5,256.99,0.05,21225);

/* insert records in product table */
CREATE TABLE vendor(
V_CODE INTEGER PRIMARY KEY,
V_NAME TEXT,
V_CONTACT TEXT,
V_AREACODE INTEGER,
V_PHONE VARCHAR(9),
V_STATE VARCHAR(3),
V_ORDER CHAR);

/* insert record in vendor table */
INSERT INTO vendor VALUES(21225,"Bryson, Inc.","Smithson",615,"223-3234","TN",'Y');
INSERT INTO vendor VALUES(21226,"SuperLoo, Inc.","Flushing",904,"215-8995","FL",'N');
INSERT INTO vendor VALUES(21231,"D&E Supply","Singh",615,"228-3245","TN",'Y');
INSERT INTO vendor VALUES(21344,"Gomez Bros.","Ortega",615,"889-2546","KY",'N');

/* query to display vendors who didn't supply any product */
--SELECT * FROM product;
--SELECT * FROM vendor;
SELECT V_CODE
FROM vendor
EXCEPT
SELECT V_CODE
FROM product;

OUTPUT OF QUERY:


Related Solutions

p .00 .01 .02 .03 .04 .05 .06 .07 .08 .09 .0 .5000 .5040 .5080 .5120...
p .00 .01 .02 .03 .04 .05 .06 .07 .08 .09 .0 .5000 .5040 .5080 .5120 .5160 .5199 .5239 .5279 .5319 .5359 .1 .5398 .5438 .5478 .5517 .5557 .5596 .5636 .5675 .5714 .5753 .2 .5793 .5832 .5871 .5910 .5948 .5987 .6026 .6064 .6103 .6141 .3 .6179 .6217 .6255 .6293 .6331 .6368 .6406 .6443 .6480 .6517 .4 .6554 .6591 .6628 .6664 .6700 .6736 .6772 .6808 .6844 .6879 .5 .6915 .6950 .6985 .7019 .7054 .7088 .7123 .7157 .7190 .7224 .6 .7257 .7291...
observation_date FEDFUNDS 1954-07-01 0.80 1954-08-01 1.22 1954-09-01 1.06 1954-10-01 0.85 1954-11-01 0.83 1954-12-01 1.28 1955-01-01 1.39...
observation_date FEDFUNDS 1954-07-01 0.80 1954-08-01 1.22 1954-09-01 1.06 1954-10-01 0.85 1954-11-01 0.83 1954-12-01 1.28 1955-01-01 1.39 1955-02-01 1.29 1955-03-01 1.35 1955-04-01 1.43 1955-05-01 1.43 1955-06-01 1.64 1955-07-01 1.68 1955-08-01 1.96 1955-09-01 2.18 1955-10-01 2.24 1955-11-01 2.35 1955-12-01 2.48 1956-01-01 2.45 1956-02-01 2.50 1956-03-01 2.50 1956-04-01 2.62 1956-05-01 2.75 1956-06-01 2.71 1956-07-01 2.75 1956-08-01 2.73 1956-09-01 2.95 1956-10-01 2.96 1956-11-01 2.88 1956-12-01 2.94 1957-01-01 2.84 1957-02-01 3.00 1957-03-01 2.96 1957-04-01 3.00 1957-05-01 3.00 1957-06-01 3.00 1957-07-01 2.99 1957-08-01 3.24 1957-09-01 3.47...
Table - 02 Hardwood Concentration 5% 10% 15% 20% 7 12 14 19 8 17 18...
Table - 02 Hardwood Concentration 5% 10% 15% 20% 7 12 14 19 8 17 18 25 15 13 19 22 11 18 17 23 9 19 16 18 10 15 18 20 A manufacturer of paper used for making grocery bags is interested in improving the tensile strength of the product. Product engineering thinks that tensile strength is a function of the hardwood concentration in the pulp and that the range of hardwood concentrations of practical interest is between...
12-A2 Customer Profitability The following table gives sales, product cost, and cost-to-serve data for a company...
12-A2 Customer Profitability The following table gives sales, product cost, and cost-to-serve data for a company that makes three product lines: A, B, and C. The company has two customer types. PRODUCT A PRODUCT B PRODUCT C Sales $5,000 $6,000 $25,000 Cost of Sales 4,500 4,800 15,000 Customer Type 1 Customer Type 2 Customer Type 3 Product A Sales $500 $4,500 $5,000 Product B Sales 1,000 5,000 6,000 Product C Sales 13,000 12,000 25,000 Manager Visits 4 16 20 The...
The accompanying table gives cost data for a firm that is selling in a purely competitive market. If the market price for the firm's product is $12, the competitive firm should produce
Total ProductAverage Fixed CostAverage Variable CostAverage Total CostMarginal Cost1$100.00$17.00$117.00$17250.0016.0066.0015333.3315.0048.3313425.0014.2539.2512520.0014.0034.0013616.6714.0030.6714714.2915.7130.0026812.5017.5030.0030911.1119.4430.55351010.0021.6031.6041119.0924.0033.0948128.3326.6735.0056The accompanying table gives cost data for a firm that is selling in a purely competitive market. If the market price for the firm's product is $12, the competitive firm should produceMultiple Choice4 units at an economic profit of $31.75.4 units at a loss of $109.zero units at a loss of $100.8 units at a loss of $48.80.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT