Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Kindly check my code below for the above project attached befor this Question, I have issue in the fact table F _ ORDERS and D
Kindly check my code below for the above project attached befor this Question, I have issue in the fact table FORDERS and DSALESMAN thay are empty no data inside the tables and I make sure every things correct. please help me with this issues.
check the code below:
Project :
SELECT from OECUSTOMERS;
CREATE TABLE CUSTOMERCOPY AS
SELECT
CUSTOMERID
CUSTFIRSTNAME,
CUSTLASTNAME,
NLSLANGUAGE,
NLSTERRITORY,
CREDITLIMIT,
CUSTEMAIL,
ACCOUNTMGRID
CUSTGEOLOCATION,
DATEOFBIRTH,
MARITALSTATUS,
GENDER,
INCOMELEVEL
FROM OECUSTOMERS;
DESCRIBE CUSTOMERCOPY
ALTER TABLE CUSTOMERCOPY
ADD TURNOVER NUMBER;
SELECT from CUSTOMERCOPY;
ALTER TABLE CUSTOMERCOPY
ADD CUSTTYPE VARCHAR;
SELECT from CUSTOMERCOPY;
select from customercopy order by customerID;
select from OEOrders order by customerID;
UPDATE CUSTOMERCOPY c
SET TURNOVER SELECT SUMoORDERTOTAL
FROM OEORDERS o
WHERE oCUSTOMERID cCUSTOMERID
GROUP BY oCUSTOMERID;
SELECT FROM customercopy;
DECLARE
avgturnover NUMBER;
BEGIN
Calculate average turnover
SELECT AVGTURNOVER INTO avgturnover FROM CUSTOMERCOPY;
Update customer type
FOR custrec IN SELECT FROM CUSTOMERCOPY LOOP
IF custrec.TURNOVER avgturnover THEN
UPDATE CUSTOMERCOPY
SET CUSTTYPE A
WHERE CUSTOMERID custrec.CUSTOMERID;
ELSIF custrec.TURNOVER avgturnover THEN
UPDATE CUSTOMERCOPY
SET CUSTTYPE B
WHERE CUSTOMERID custrec.CUSTOMERID;
ELSE
UPDATE CUSTOMERCOPY
SET CUSTTYPE C
WHERE CUSTOMERID custrec.CUSTOMERID;
END IF;
END LOOP;
END;
SELECT FROM customercopy;
SELECT CUSTTYPE, COUNT AS NUMCUSTOMERS
FROM CUSTOMERCOPY
GROUP BY CUSTTYPE;
SELECT COUNT AS TOTALCUSTOMERS
FROM CUSTOMERCOPY;
SELECT COUNTDISTINCT NLSTERRITORY AS NUMCOUNTRIES
FROM OECUSTOMERS;
CREATE TABLE CURRENCYRATES
CURSIGN CHAR
COUNTRY VARCHAR
CURQTY NUMBER
EURORATE NUMBER
;
INSERT INTO CURRENCYRATES CURSIGN, COUNTRY, CURQTY EURORATE
VALUES CNY 'CHINA',
;
INSERT INTO CURRENCYRATES CURSIGN, COUNTRY, CURQTY EURORATE
VALUES INR 'INDIA',
;
INSERT INTO CURRENCYRATES CURSIGN, COUNTRY, CURQTY EURORATE
VALUES CHF 'SWITZERLAND',
;
INSERT INTO CURRENCYRATES CURSIGN, COUNTRY, CURQTY EURORATE
VALUES THB 'THAILAND',
;
INSERT INTO CURRENCYRATES CURSIGN, COUNTRY, CURQTY EURORATE
VALUES JPY 'JAPAN',
;
INSERT INTO CURRENCYRATES CURSIGN, COUNTRY, CURQTY EURORATE
VALUES EUR 'ITALY',
;
INSERT INTO CURRENCYRATES CURSIGN, COUNTRY, CURQTY EURORATE
VALUES USD 'AMERICA',
;
INSERT INTO CURRENCYRATES CURSIGN, COUNTRY, CURQTY EURORATE
VALUES EUR 'GERMANY',
;
SELECT FROM CURRENCYRATES
;
CREATE TABLE ORDERSINEURO AS
SELECT
OORDERID
OCUSTOMERID
CNLSTERRITORY AS COUNTRY,
OORDERTOTAL,
OORDERTOTAL CREURORATE AS ORDERTOTALEURO
FROM
OEORDERS O
JOIN
OECUSTOMERS C ON OCUSTOMERID CCUSTOMERID
JOIN
CURRENCYRATES CR ON CNLSTERRITORY CRCOUNTRY
;
CREATE OR REPLACE FUNCTION CONVERTTOEURO
pordertotal IN NUMBER,
pcountry IN VARCHAR
RETURN NUMBER AS
veurorate NUMBER;
BEGIN
SELECT EURORATE INTO veurorate
FROM CURRENCYRATES
WHERE COUNTRY pcountry;
RETURN pordertotal veurorate;
EXCEPTION
WHEN NODATAFOUND THEN
RETURN NULL;
END CONVERTTOEURO;
UPDATE ORDERSINEURO
SET ORDERTOTALEURO CONVERTTOEUROORDERTOTAL, COUNTRY
;
SELECT FROM ORDERSINEURO
;
Project and in the attached pictures because it is not allowed here to write more. and for more clarification the project & is corrected and I submitted now I need to resolve project
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started