SQL プラスの使用
次の点について支援が必要です: パッケージの種類別に分類された、任意の日の売上の概要 (つまり、支払った請求書ではなく、顧客が購読した各パッケージの指定された日の総売上)。このレポートには、各パッケージの種類、パッケージの価格、販売されたパッケージの数、およびそのパッケージの合計販売額に関する詳細が表示されます。繰り返しになりますが、これは日付主導のレポートになることに注意してください。
SET ECHO ON
SPOOL C:\CIS336\InfoMiners\Week7\Final\InfoMiners_Week7_Task5_FinalSpool.txt
SET LINESIZE 120
SET PAGESIZE 45
SET FEEDBACK 1
-- CIS-336 Online
-- XXXXX XXXXX
-- InfoMiners Week 7 - Task 5 - Reports
-- april 15, 2012
-- DROP Table Statements
DROP TABLE package_guide CASCADE CONSTRAINTS PURGE;
DROP TABLE employee CASCADE CONSTRAINTS PURGE;
DROP TABLE customer CASCADE CONSTRAINTS PURGE;
DROP TABLE cust_survey CASCADE CONSTRAINTS PURGE;
DROP TABLE bill_info CASCADE CONSTRAINTS PURGE;
DROP TABLE package CASCADE CONSTRAINTS PURGE;
DROP TABLE channel CASCADE CONSTRAINTS PURGE;
DROP TABLE program CASCADE CONSTRAINTS PURGE;
DROP TABLE ratings CASCADE CONSTRAINTS PURGE;
DROP TABLE network_supplier CASCADE CONSTRAINTS PURGE;
-- CREATE Table Statements
CREATE TABLE network_supplier
(
supplier_id VARCHAR2(15) CONSTRAINT pk_supplier_id PRIMARY KEY,
supplier_name VARCHAR2(15) NOT NULL,
address VARCHAR2(25) NOT NULL,
city VARCHAR2(17) NOT NULL,
state CHAR(2) NOT NULL,
zip_code NUMBER(5) NOT NULL,
contact_name VARCHAR2(20) NOT NULL,
contact_phone VARCHAR2(14) NOT NULL
);
CREATE TABLE ratings
(
rating_code VARCHAR2(17) CONSTRAINT pk_rating_code PRIMARY KEY,
rating_description VARCHAR2(70)
);
CREATE TABLE program
(
program_id NUMBER(17) CONSTRAINT pk_program_id PRIMARY KEY,
name VARCHAR2(70) NOT NULL,
supplier_id VARCHAR2(15) REFERENCES network_supplier(supplier_id),
length NUMBER(5) NOT NULL,
description VARCHAR2(30),
type VARCHAR2 (15) NOT NULL,
rating_code VARCHAR2(17) REFERENCES ratings(rating_code)
);
CREATE TABLE channel
(
channel_id VARCHAR2(20) CONSTRAINT pk_channel_id PRIMARY KEY,
ch_number NUMBER(2) NOT NULL,
name VARCHAR2(20) NOT NULL,
type VARCHAR2(20) NOT NULL,
customer_count NUMBER(30) NOT NULL,
supplier_id VARCHAR2(15) REFERENCES network_supplier(supplier_id),
show_time TIMESTAMP NOT NULL
);
CREATE TABLE package
(
package_id VARCHAR2(2) CONSTRAINT pk_package_id PRIMARY KEY,
name VARCHAR2(25) NOT NULL,
cost NUMBER(5) NOT NULL
);
CREATE TABLE bill_info
(
acct_num NUMBER(10) CONSTRAINT pk_acct_num PRIMARY KEY,
balance NUMBER(5) NOT NULL,
due_date DATE NOT NULL,
acct_current NUMBER(1),
package_id VARCHAR2(2) REFERENCES package(package_id)
);
CREATE TABLE cust_survey
(
survey_id VARCHAR2(20) CONSTRAINT pk_survey_id PRIMARY KEY,
fav_channel VARCHAR2(20) NOT NULL,
months_paid NUMBER(3) NOT NULL
);
CREATE TABLE customer
(
customer_id NUMBER(10) CONSTRAINT pk_customer_id PRIMARY KEY,
active_date DATE NOT NULL,
cancel_date DATE,
cancel_reason NUMBER(1),
first_name VARCHAR2(10) NOT NULL,
last_name VARCHAR2(10) NOT NULL,
address VARCHAR2(25) NOT NULL,
city VARCHAR2(15) NOT NULL,
state CHAR(2) NOT NULL,
zip_code NUMBER(5) NOT NULL,
phone_num NUMBER(10) NOT NULL,
acct_num NUMBER(10) REFERENCES bill_info(acct_num) NOT NULL,
survey_id VARCHAR2(20) REFERENCES cust_survey(survey_id) NOT NULL,
package_id VARCHAR2(2) REFERENCES package(package_id) NOT NULL,
email VARCHAR(20) NOT NULL
);
CREATE TABLE employee
(
emp_num NUMBER(11) CONSTRAINT pk_emp_num PRIMARY KEY,
first_name VARCHAR2(10) NOT NULL,
last_name VARCHAR2(10) NOT NULL,
emp_phone NUMBER(10) NOT NULL
);
CREATE TABLE package_guide
(
package_id REFERENCES package(package_id) NOT NULL,
channel_id REFERENCES channel(channel_id) NOT NULL,
program_id REFERENCES program(program_id) NOT NULL
);
-- INSERT Statements
-- Data for network_supplier Table (4 Records)
INSERT INTO network_supplier (supplier_id, supplier_name, address, city, state, zip_code, contact_name, contact_phone)
VALUES (1, 'NBC', '10880 Wilshire Blvd #1200', 'Los Angeles', 'CA', 90057, 'XXXXX XXXXX', '(XXX) XXX-XXXX' );
INSERT INTO network_supplier (supplier_id, supplier_name, address, city, state, zip_code, contact_name, contact_phone)
VALUES (2, 'ABC', '111 Hollywood Blvd.', 'Los Angeles', 'CA', 90046, 'Jack Carverisi', '(XXX) XXX-XXXX' );
INSERT INTO network_supplier (supplier_id, supplier_name, address, city, state, zip_code, contact_name, contact_phone)
VALUES (3, 'FOX', '10960 Wilshire Blvd', 'Los Angeles', 'CA', 90057, 'Janis Carmikel', '(XXX) XXX-XXXX' );
INSERT INTO network_supplier (supplier_id, supplier_name, address, city, state, zip_code, contact_name, contact_phone)
VALUES (4, 'WARNER', '3701 W Oak St.', 'Burbank', 'CA', 91501, 'Simon Philips', '(XXX) XXX-XXXX' );
-- Data for ratings Table (7 Records)
INSERT INTO ratings (rating_code, rating_description)
VALUES ('TV-Y', 'All Children');
INSERT INTO ratings
VALUES ('TV-Y7', 'Directed to Older Children');
INSERT INTO ratings
VALUES ('TV-Y7-FV', 'Directed to Older Children - Fantasy Viol
既に試しました: select ステートメントのさまざまなバリエーションですが、サブクエリを使用して select ステートメントを完全に機能させることを理解していません。
続きを読む: SQL Plus の宿題の質問 - JustAnswer http://www.justanswer.com/computer-programming/6j1qs-sql-plus-homework-question.html#ixzz1sA4U5tTz