Please answer Question 3 parts A and B in the image. The tricky part is only new lines can be added and the original script must stay unaltered. (3) Craft a SQL Select statement to illustrate the following: (A) SQL Series One: CRAFT a SELECT statement that returns two columns of the ORDERLINEITEM table: 1) Use CAST function to return UnitPrice as data type decimal with 2 digits to the right of the decimal point 2) Use CAST function to return UnitPrice as data type varchar. 3) Use CONVERT function to return UnitPrice s data type decimal with 2 digits to the right of the decimal point. 4) Use CONVERT function to return UnitPrice as data type varchar, using style 1.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

please abswer both a and b parts within 30 minutes..

Here is my original SQL script. Please answer Question 3 parts A and B in the image. The tricky part is only new lines can be added and the original script must stay unaltered. Thanks for your help!

-------------------------------------------------------------------------------------------------------

-- ORDERS DATABASE objects
CREATE TABLE CUSTOMER
(
CustomerID INT NOT NULL PRIMARY KEY,
CustomerName VARCHAR (50) NOT NULL,
CustomerAddress VARCHAR(50) NOT NULL,
CustomerPrimaryPhone VARCHAR(10) NULL
);
--
CREATE TABLE CUSTOMERORDER
(
OrderID INT NOT NULL PRIMARY KEY,
CustomerID INT NOT NULL FOREIGN KEY REFERENCES CUSTOMER(CustomerID),
OrderDate DATE NOT NULL,
ShipAddress VARCHAR(50) NOT NULL,
ShipDate DATE NOT NULL
);
--
CREATE TABLE PRODUCT
(
ProductID INT NOT NULL PRIMARY KEY,
ProductName VARCHAR(50) NOT NULL,
UnitPrice DECIMAL(10,2) NOT NULL,
AvailabilityStatus VARCHAR(10) NOT NULL
);
--
CREATE TABLE ORDERLINEITEM
(
OrderID INT NOT NULL,
OrderSequence INT NOT NULL,
ProductID INT NOT NULL,
Quantity INT NOT NULL DEFAULT 0 CHECK (Quantity >=0),
UnitPrice DECIMAL(10,2) NOT NULL,
PRIMARY KEY (OrderID, OrderSequence),
FOREIGN KEY (OrderID) REFERENCES CUSTOMERORDER(OrderID),
FOREIGN KEY (ProductID) REFERENCES PRODUCT(ProductID)
);
-- Revise objects
ALTER TABLE CUSTOMER
DROP COLUMN CustomerAddress;
--
ALTER TABLE CUSTOMER
ADD CustomerStreet VARCHAR(50) NOT NULL,
CustomerCity VARCHAR(50) NOT NULL,
CustomerState CHAR(2) NOT NULL,
CustomerZipCode VARCHAR(10) NOT NULL;
--
ALTER TABLE CUSTOMERORDER
DROP COLUMN ShipAddress;
--
ALTER TABLE CUSTOMERORDER
ADD ShipStreet VARCHAR(50) NOT NULL,
ShipCity VARCHAR(50) NOT NULL,
ShipState CHAR(2) NOT NULL,
ShipZipCode VARCHAR(10) NOT NULL;
--


--DML Script (insert data)
INSERT INTO CUSTOMER (CustomerID, CustomerName, CustomerPrimaryPhone, CustomerStreet, CustomerCity, CustomerState, CustomerZipCode)
VALUES (1, 'Joe', 3369991450, '123 Main', 'Raleigh', 'NC', 28201),
(2, 'Sandy',5032217777, '40th Avenue', 'Sandy', 'OR', 99887),
(3, 'Ben', 3608889999, '491 Street', 'Vancouver', 'WA', 98683);
select * from CUSTOMER;


INSERT INTO CUSTOMERORDER (OrderID, CustomerID, OrderDate, ShipDate, ShipStreet, ShipCity, ShipState, ShipZipCode)
VALUES (1, 1,'09/01/2022', '09/2/2022', '123 Main', 'Raleigh', 'NC', 28201),
(2, 2,'09/03/2022', '09/11/2022', '40th Avenue', 'Sandy', 'OR', 99887),
(3, 3,'08/01/2022', '08/31/2022', '491 Street', 'Vancouver', 'WA', 98683);
select * from CUSTOMERORDER;

INSERT INTO PRODUCT (ProductID, ProductName, UnitPrice, AvailabilityStatus)
VALUES (1, 'Textbook', 125.13,'Available'),
(2, 'Laptop', 455.99, 'BackOrder'),
(3, 'Chair', 124.88,'Available');
select * from PRODUCT;


INSERT INTO ORDERLINEITEM (OrderID, OrderSequence, ProductID, Quantity, UnitPrice)
VALUES (1, 1, 1, 1, 125.13),
(1, 2, 2, 1, 455.99),
(1, 3, 3, 1, 124.88);
select * from ORDERLINEITEM;

----------------------------------------------------------------------------------------------------------------------

Please answer Question 3 parts A and B in the image. The tricky part is only
new lines can be added and the original script must stay unaltered.
(3) Craft a SQL Select statement to illustrate the following:
(A) SQL Series One:
CRAFT a SELECT statement that returns two columns of the ORDERLINEITEM table:
1)
Use CAST function to return UnitPrice as data type decimal with 2 digits to the right of the decimal point
Use CAST function to return UnitPrice as data type varchar.
2)
3) Use CONVERT function to return UnitPrice s data type decimal with 2 digits to the right of the decimal point.
4) Use CONVERT function to return UnitPrice as data type varchar, using style 1.
Remember to include the original columns in your result set along with new headings of the revised columns in your result set.
(B) SQL Series Two.
CRAFT a SELECT statement that returns two columns of the CUSTOMERORDER table:
1)
Use CAST function to return OrderDate as data type varchar.
2)
Use CONVERT function to return ShipDate as data type varchar, using style 1.
3) Use CONVERT function to return ShipDate as data type varchar, using style 10.
Remember to include the original columns in your result set along with new headings of the revised columns in your result set.
Transcribed Image Text:Please answer Question 3 parts A and B in the image. The tricky part is only new lines can be added and the original script must stay unaltered. (3) Craft a SQL Select statement to illustrate the following: (A) SQL Series One: CRAFT a SELECT statement that returns two columns of the ORDERLINEITEM table: 1) Use CAST function to return UnitPrice as data type decimal with 2 digits to the right of the decimal point Use CAST function to return UnitPrice as data type varchar. 2) 3) Use CONVERT function to return UnitPrice s data type decimal with 2 digits to the right of the decimal point. 4) Use CONVERT function to return UnitPrice as data type varchar, using style 1. Remember to include the original columns in your result set along with new headings of the revised columns in your result set. (B) SQL Series Two. CRAFT a SELECT statement that returns two columns of the CUSTOMERORDER table: 1) Use CAST function to return OrderDate as data type varchar. 2) Use CONVERT function to return ShipDate as data type varchar, using style 1. 3) Use CONVERT function to return ShipDate as data type varchar, using style 10. Remember to include the original columns in your result set along with new headings of the revised columns in your result set.
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY