SELECT CUSTID, (SELECT ADDRESS
FROM CUSTOMER CS
WHERE CS.CUSTID = OD.CUSTID) "ADDRESS",
SUM(OD.SALEPRICE) "TOTAL"
FROM ORDERS OD
GROUP BY OD.CUSTID;
SELECT CS.NAME, S
FROM (SELECT CUSTID, AVG(SALEPRICE) S
FROM ORDERS
GROUP BY CUSTID) OD,
CUSTOMER CS
WHERE CS.CUSTID=OD.CUSTID;
CREATE VIEW VW_CUSTOMER
AS SELECT *
FROM CUSTOMER
WHERE ADDRESS LIKE '%대한민국%';
SELECT * FROM VW_CUSTOMER;
CREATE VIEW HIGHORDERS
AS SELECT ORDERS.BOOKID, BOOK.BOOKNAME, CUSTOMER.NAME, BOOK.PUBLISHER, ORDERS.SALEPRICE
FROM ORDERS, BOOK, CUSTOMER
WHERE BOOK.BOOKID = ORDERS.BOOKID
AND ORDERS.CUSTID = CUSTOMER.CUSTID
AND ORDERS.SALEPRICE >= 20000;
SELECT BOOKNAME, NAME
FROM HIGHORDERS;
SELECT *
FROM HIGHORDERS;
CREATE OR REPLACE VIEW HIGHORDERS
AS SELECT ORDERS.BOOKID, BOOK.BOOKNAME, CUSTOMER.NAME, BOOK.PUBLISHER
FROM ORDERS, BOOK, CUSTOMER
WHERE BOOK.BOOKID = ORDERS.BOOKID
AND ORDERS.CUSTID = CUSTOMER.CUSTID
AND ORDERS.SALEPRICE >= 20000;
CREATE INDEX NAME ON CUSTOMER(NAME);
DROP INDEX NAME;
'IT > Oracle' 카테고리의 다른 글
오라클 pl/sql 데이터타입, reference type(%type, %rowtype), composite type(record, table), 조건문(if, case), 반복문(for, while, loop) (0) | 2018.07.29 |
---|---|
오라클 계정비밀번호 변경 및 unlock (0) | 2018.07.28 |
오라클 쿼리 실습예제. 서브쿼리, join, exists, in (0) | 2018.07.25 |
다이어그램 ERD 그리기, 외래키 연결 (0) | 2018.07.23 |
이클립스 exerd 추가, 오라클 dbms 연결설정 및 db 포워드 (0) | 2018.07.23 |