CREATE TABLE PRODUCTS AS select DISTINCT
"PROD_ID",
"PROD_NAME",
"PROD_DESC"
from SH."PRODUCTS"
Table created.
analyze table "PRODUCTS" compute statistics
Statement processed.
CREATE TABLE SALES_HIST_012000 AS
select DISTINCT
SH.SALES.*
from SH.SALES
INNER JOIN PRODUCTS ON SH.SALES.PROD_ID = PRODUCTS.PROD_ID
WHERE TO_cHAR(TIME_ID, 'mm-yyyy') = '01-2000'
Table created.
analyze table "SALES_HIST_012000" compute statistics
Statement processed.
CREATE TABLE CUSTOMERS AS
SELECT * FROM
(
select DISTINCT
CUST_ID
, CUST_FIRST_NAME
, CUST_LAST_NAME
, ROW_NUMBER() OVER (PARTITION BY CUST_FIRST_NAME, CUST_LAST_NAME ORDER BY CUST_FIRST_NAME, CUST_LAST_NAME ) RN
from SH.CUSTOMERS
)
WHERE RN = 1
Table created.
alter table "CUSTOMERS" DROP COLUMN RN
Table altered.
analyze table "CUSTOMERS" compute statistics
Statement processed.
create view v_customer_sales_jan2000 as
SELECT
cs.cust_id,
pr.prod_id,
cust_first_name
, cust_last_name
, to_char(time_id, 'DD-MON-YYYY') as "date"
, prod_name
, quantity_sold
, amount_sold
FROM CUSTOMERS cs
inner join sales_hist_012000 sh
on cs.cust_id = sh.cust_id
inner join products pr on
sh.prod_id = pr.prod_id
View created.