Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please answer all questions in the picture by a screenshot for each question I put all codes just answer the question which is in the

image text in transcribedplease answer all questions in the picture by a screenshot for each question I put all codes just answer the question which is in the paper

CREATE TABLE customerOrder(

orderNo int,

orderDate varchar(15) NOT NULL,

customerNo varchar(5),

PRIMARY KEY (orderNo),

FOREIGN KEY (customerNo) REFERENCES Customer(customerNo));

INSERT INTO customerOrder Values (30178 ,'01-DEC-2017','C400');

INSERT INTO customerOrder Values (30179 ,'02-DEC-2017','B512');

INSERT INTO customerOrder Values (30182,'03-DEC-2017','C400');

INSERT INTO customerOrder Values (30184 ,'03-DEC-2017','B062');

INSERT INTO customerOrder Values (30185,'02-JAN-2018','B332');

INSER INSERT INTO customerOrder Values (30188 ,'03-JAN-2018','C003');

INSERT INTO customerOrder Values (30186,'02-JAN-2018','C400');

INSERT INTO customerOrder Values (31693 ,'022-DEC-2019','S600');

INSERT INTO customerOrder Values (37541 ,'15-DEC-2019','B587');

INSERT INTO customerOrder Values (33242,'04-DEC-2018','C932');

INSERT INTO customerOrder Values (39964 ,'08-SEP-2017','B337');

INSERT INTO customerOrder Values (34792,'02-MARCH-2018','B396');

 

CREATE TABLE Price143 ( priceCode INTEGER(20), newPrice decimal(9,2), originalPrice decimal(9,2), productNO char(10), PRIMARY KEY(priceCode), FOREIGN KEY (productNO) REFERENCES product143(ProductNo) );

INSERT INTO Price143 VALUES (2413,50,40.1,'3');

INSERT INTO Price143 VALUES (2852,150,120.0,'9');

INSERT INTO Price143 VALUES (2521,70,60.8,'0');

INSERT INTO Price143 VALUES (3512,1000,900.7,'1');

INSERT INTO Price143 VALUES (2466,30,20.75,'2');

INSERT INTO Price143 VALUES (2365,76,70.5,'7');

INSERT INTO Price143 VALUES (1235,10,7.0,'5');

INSERT INTO Price143 VALUES (9531,60,50.2,'3');

INSERT INTO Price143 VALUES (6312,120,110.7,'20');

INSERT INTO Price143 VALUES (2331,800,750.6,'16');

CREATE TABLE Product143( productNO char(10), label varchar(30), price decimal(9,2), QStock INTEGER(11), PRIMARY KEY(productNO) );

INSERT INTO Product Values ('CS262','Chev.fir 200x6x2',75,45);

INSERT INTO Product Values ('CS264','Chev.fir 200x6x4',120 ,2690);
INSERT INTO Product Values ('CS464','Chev.fir 400x6x4', 220,450);
INSERT INTO Product Values ('PA45','Steel point 45 (1K)', 105,580);
INSERT INTO Product Values ('PA60','Steel point 60 (1K)', 95,134);
INSERT INTO Product Values ('PH222','PL.Hetre 200x20x2', 230,782);
INSERT INTO Product Values ('PS222','PL.fir 200x20x2', 185,1220);
INSERT INTO Product Values ('TRT989','Chev.fir 210x5x2',75,45);
INSERT INTO Product Values ('CS954','Chev.fir 260x7x4',170 ,2690);
INSERT INTO Product Values ('GH454','Chev.fir 350x8x4', 220,450);
INSERT INTO Product Values ('PN60','Steel point 66 (1K)', 145,590);
INSERT INTO Product Values ('JK50','Steel point 50 (1K)', 35,754);

CREATE TABLE orderedProduct( orderNO int, productNo varchar(5), orderQuantity int NOT NULL, FOREIGN KEY (orderNO) REFERENCES customerOrder(orderNO), FOREIGN KEY (productNo) REFERENCES Product(productNo),

INSERT INTO orderedProduct Values ( 30178,'CS464', 25);

INSERT INTO orderedProduct Values ( 30179,'CS262', 60);

INSERT INTO orderedProduct Values ( 30179,'PA60', 20);

INSERT INTO orderedProduct Values ( 30182,'PA60', 30);

INSERT INTO orderedProduct Values ( 30184,'CS464', 120);

INSERT INTO orderedProduct Values ( 30184,'PA45', 20);

INSERT INTO orderedProduct Values ( 30185,'CS464', 260);

INSERT INTO orderedProduct Values ( 30185,'PA60', 15);

INSERT INTO orderedProduct Values ( 30186,'PS222', 600);

INSERT INTO orderedProduct Values ( 30186,'PA45', 3);

INSERT INTO orderedProduct Values ( 30188,'PA60', 180);

INSERT INTO orderedProduct Values ( 30188,'PH222', 92);

INSERT INTO orderedProduct Values ( 30745,'GH564', 65); INSERT INTO orderedProduct Values ( 30632,'GF732', 10); INSERT INTO orderedProduct Values ( 30074,'JW660', 50); INSERT INTO orderedProduct Values ( 39935,'TY60', 30); INSERT INTO orderedProduct Values ( 34367,'GH664', 120);

CREATE TABLE Customer143(

customerNO char(8),

customerName varchar(20),

address VARchar(40),

city varchar(20),

category char(2),

custBalance decimal(9,2),

PRIMARY KEY(customerNO)

);

INSERT INTO Customer Values ('B062','Ahmed','72 street Freedom','Salalah','B2',-100);

INSERT INTO Customer Values ('B112','Salim','Street Sultan Qaboos','Muscat','C1', 1250);

INSERT INTO Customer Values ('B332','Alia','Building Hana Street Alhisn ','Ibri','B2', 0);

INSERT INTO Customer Values ('B512','Taoufiq','Building Alaamra','Rustaq','B1', -500);

INSERT INTO Customer Values ('C003','Islam','House N 5 Street Asahafa','Salalah','B1', -1000);

INSERT INTO Customer Values ('C123','Murad','Building Asalalm Main Street','Ibri','C1', -2000);

NSERT INTO Customer Values ('C400','Jamilah','Street of garden House n 5','Muscat','B2', 350);

INSERT INTO Customer Values ('B062', 'Ahmed', '55 FINS BEACH', 'QURAIT', '42', 60);

INSERT INTO Customer Values ('B112', 'REEM', 'Street Sultan Qaboos', 'Muscat', 'H6', 150);

INSERT INTO Customer Values ('B332', 'Ali', 'WADI SHAB ','SUR', 'G4', 0);

INSERT INTO Customer Values ('B512', 'RANA', 'NIZWA FORT', 'NIZWA', 'VI', 100);

INSERT INTO Customer Values ('C003', 'WAFA', 'AL ALAM PALACE', 'MUSCAT', 'KL', 900);

3) Open a new SQL worksheet then write in SQL the queries, which answer the questions below. Save the script as queries.sql. (write the number of question as comment before each query) a) Display in alphabetical order the list of cities in which there is at least one customer.[0.5] b) Display the number, name and city of customers who belong to category C1 and who are not living in Muscat. [0.5] c) List the characteristics of products made of steel.[0.5] d) Display the details of products having a price under 200 and a stock more than 150.[0.5] e) List the number, name and balance of customers who are from Salalah or Ibri and whose balance is positive. [0.5] f) List the number of cities in which there are customers of category C1.[0.5] g) Display the number of customers who have placed at least one order. [0.5] h) Calculate, for each city, the number of distinct categories. [0.75] i) Assign zero to the balance of customers of category C1 and whose balance is negative. [0.75] j) Change to 10 units the ordered quantity of the product number PA60 in the order number 30185.(0.75] k) Calculate the total amount in the stock of products made of fir. [0.75] 1) Display the details (orderNO, order Date of the most recent order.[1] m) Display the details of orders (orderNO, orderDate, customerNO ) which doesn't include the products having the code PA60. [1] n) Display numbers and names of customers who are from Muscat and have not placed orders. [1] 0) Display numbers of products (productNO) which are made of fir and are placed in orders. p) Find for each product the list of cities in which this product is ordered in more than 500 units.[1.5] q) List, for each customer category, the number of products that were ordered on 23-12- 2008.[1.5) 4) Open a new SQL worksheet then write a SQL statement to create a view named orderPerClient' which will contain the number of orders placed by each customer. Save this script as view_creation.sql. [1.5] 5) Create a new folder named assignment1_yourID. Put in this folder all the scripts created in the above questions. Compress the folder then submit it via Blackboard on or before

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions

Question

7. Be able to distinguish productive from destructive conflict.

Answered: 1 week ago

Question

How does selection differ from recruitment ?

Answered: 1 week ago

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago