Journal PLSQL

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 36

1) ~ TABLE :- CLIENT_MASTER

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

COMMAND :- CREATE TABLE CLIENT_MASTER


(
CLIENTNO VARCHAR2(6) PRIMARY KEY,
NAME VARCHAR2(20) NOT NULL,
ADDRESS1 VARCHAR2(30),
ADDRESS2 VARCHAR2(30),
CITY VARCHAR2(15),
PINCODE NUMBER(8),
STATE VARCHAR2(15),
BALDUE NUMBER(10,2)
);

STRUCTURE :-

Name Null? Type


------------------------------- -------- ----
CLIENTNO NOT NULL VARCHAR2(6)
NAME NOT NULL VARCHAR2(20)
ADDRESS1 VARCHAR2(30)
ADDRESS2 VARCHAR2(30)
CITY VARCHAR2(15)
PINCODE NUMBER(8)
STATE VARCHAR2(15)
BALDUE NUMBER(10,2)

2) ~ TABLE :- PRODUCT_MASTER

COMMAND :- CREATE TABLE PRODUCT_MASTER


(
PRODUCTNO VARCHAR2(6) CHECK(PRODUCTNO LIKE 'P%'),
DESCRIPTION VARCHAR2(15) NOT NULL,
PROFITPERCENT NUMBER(4,2) NOT NULL,
UNITMEASURE VARCHAR2(10) NOT NULL,
QTYONHAND NUMBER(8) NOT NULL,
REORDERLVL NUMBER(8) NOT NULL,
SELLPRICE NUMBER(8,2) NOT NULL,
COSTPRICE NUMBER(8,2) NOT NULL,
PRIMARY KEY(PRODUCTNO)
);
STRUCTURE :-

Name Null? Type


------------------------------- -------- ----
PRODUCTNO NOT NULL VARCHAR2(6)
DESCRIPTION NOT NULL VARCHAR2(15)
PROFITPERCENT NOT NULL NUMBER(4,2)
UNITMEASURE NOT NULL VARCHAR2(10)
QTYONHAND NOT NULL NUMBER(8)
REORDERLVL NOT NULL NUMBER(8)
SELLPRICE NOT NULL NUMBER(8,2)
COSTPRICE NOT NULL NUMBER(8,2)

3) ~ TABLE :- SALESMAN_MASTER
---------------

COMMAND :- CREATE TABLE SALESMAN_MASTER


(
SALESMANNO VARCHAR2(6) CHECK(SALESMANNO LIKE 'S%'),
SALESMANNAME VARCHAR2(20) NOT NULL,
ADDRESS1 VARCHAR2(30) NOT NULL,
ADDRESS2 VARCHAR2(30),
CITY VARCHAR2(20),
PINCODE NUMBER(8),
STATE VARCHAR2(20),
SALAMT NUMBER(8,2) NOT NULL,
TGTTOGET NUMBER(6,2) NOT NULL,
YTDSALES NUMBER(6,2) NOT NULL,
REMARKS VARCHAR2(60),
PRIMARY KEY(SALESMANNO) );

STRUCTURE :-
Name Null? Type
------------------------------- -------- ----
SALESMANNO NOT NULL VARCHAR2(6)
SALESMANNAME NOT NULL VARCHAR2(20)
ADDRESS1 NOT NULL VARCHAR2(30)
ADDRESS2 VARCHAR2(30)
CITY VARCHAR2(20)
PINCODE NUMBER(8)
STATE VARCHAR2(20)
SALAMT NOT NULL NUMBER(8,2)
TGTTOGET NOT NULL NUMBER(6,2)
YTDSALES NOT NULL NUMBER(6,2)
REMARKS VARCHAR2(60)

4) ~ TABLE :- SALES_ORDER
-----------

COMMAND :- CREATE TABLE SALES_ORDER


(
ORDERNO VARCHAR2(6),
CLIENTNO VARCHAR2(6) REFERENCES CLIENT_MASTER,
ORDERDATE DATE NOT NULL,
DELYADDR VARCHAR2(25),
SALESMANNO VARCHAR2(6) REFERENCES SALESMAN_MASTER,
DELYTYPE CHAR(1) DEFAULT 'F',
BILLYN CHAR(1),
DELYDATE DATE,
ORDERSTATUS VARCHAR2(10),
constraints pk_value PRIMARY KEY(ORDERNO)
);
alter table SALES_ORDER
add ( constraints pk_value PRIMARY KEY(ORDERNO),
constraints chk_ordstat check ( ORDERSTATUS in ( ' In Process ', 'FullFill ', 'BackOrder','Cancelled'))
);

STRUCTURE :-
Name Null? Type
------------------------------- -------- ----
ORDERNO NOT NULL VARCHAR2(6)
CLIENTNO VARCHAR2(6)
ORDERDATE NOT NULL DATE
DELYADDR VARCHAR2(25)
SALESMANNO VARCHAR2(6)
DELYTYPE CHAR(1)
BILLYN CHAR(1)
DELYDATE DATE
ORDERSTATUS VARCHAR2(10)

5) ~ TABLE :- SALES_ORDER_DETAILS
-------------------

COMMAND :- CREATE TABLE SALES_ORDER_DETAILS


(
ORDERNO VARCHAR2(6) REFERENCES SALES_ORDER,
PRODUCTNO VARCHAR2(6) REFERENCES PRODUCT_MASTER,
QTYORDERED NUMBER(8),
QTYDISP NUMBER(8),
PRODUCTRATE NUMBER(10,2) );
STRUCTURE :-

Name Null? Type


------------------------------- -------- ----
ORDERNO VARCHAR2(6)
PRODUCTNO VARCHAR2(6)
QTYORDERED NUMBER(8)
QTYDISP NUMBER(8)
PRODUCTRATE NUMBER(10,2)

6) ~ TABLE :- CHALLAN_HEADER
--------------

COMMAND :- CREATE TABLE CHALLAN_HEADER


(
CHALLAN_NO VARCHAR2(6) PRIMARY KEY,
CHECK(CHALLAN_NO LIKE 'CH%'),
ORDER_NO VARCHAR2(6) REFERENCES SALES_ORDER,
CHALLAN_DATE DATE NOT NULL,
BILLED_YN CHAR(1) DEFAULT 'N'
);

STRUCTURE :-
Name Null? Type
------------------------------- -------- ----
CHALLAN_NO NOT NULL VARCHAR2(6)
ORDER_NO VARCHAR2(6)
CHALLAN_DATE NOT NULL DATE
BILLED_YN CHAR(1)

7) ~ TABLE :- CHALLAN_DETAILS
---------------

COMMAND :- CREATE TABLE CHALLAN_DETAILS


(
CHALLAN_NO VARCHAR2(6) REFERENCES CHALLAN_HEADER,
PRODUCTNO VARCHAR2(6) REFERENCES PRODUCT_MASTER,
QTY_DISP NUMBER(8) NOT NULL);
STRUCTURE :-
Name Null? Type
------------------------------- -------- ----
CHALLAN_NO VARCHAR2(6)
PRODUCTNO VARCHAR2(6)
QTY_DISP NOT NULL NUMBER(8)
QUE. :- 2 INSERT INTO DATA IN THE ABOVE TABLE.

1) ~ TABLE :- CLIENT_MASTER
-------------
COMMAND :-
-------
INSERT INTO CLIENT_MASTER(CLIENTNO,NAME,CITY,PINCODE,STATE,BALDUE)
VALUES('C00007','KAVITA PATEL','PUNE',411057,'MAHARASHTRA',8000);

INSERT INTO CLIENT_MASTER(CLIENTNO,NAME,CITY,PINCODE,STATE,BALDUE)


VALUES('C00008','RAJESH JAIN','CHENNAI',600001,'TAMIL NADU',12000);

INSERT INTO CLIENT_MASTER(CLIENTNO,NAME,CITY,PINCODE,STATE,BALDUE)


VALUES('C00009','SNEHA SHARMA','HYDERABAD',500001,'TELANGANA',9000);

INSERT INTO CLIENT_MASTER(CLIENTNO,NAME,CITY,PINCODE,STATE,BALDUE)


VALUES('C00010','RAMESH KUMAR','BANGALORE',560001,'KARNATAKA',6000);

INSERT INTO CLIENT_MASTER(CLIENTNO,NAME,CITY,PINCODE,STATE,BALDUE)


VALUES('C00011','PREETI GUPTA','MUMBAI',400054,'MAHARASHTRA',10000);

RECORD :-
------
CLIENT NAME ADDRESS1 ADDRESS2 CITY PINCODE STATE BALDUE
------ --------------- --------------- --------------- --------------- --------- ------------ ---------
C00007 KAVITA PATEL PUNE PUNE 411057 MAHARASHTRA 8000
C00008 RAJESH JAIN CHENNAI CHENNAI 600001 TAMIL NADU 12000
C00009 SNEHA SHARMA HYDERABAD HYDERABAD 500001 TELANGANA 9000
C00010 RAMESH KUMAR BANGALORE BANGALORE 560001 KARNATAKA 6000
C00011 PREETI GUPTA MUMBAI MUMBAI 400054 MAHARASHTRA 10000
2) ~ TABLE :- PRODUCT_MASTER
--------------

COMMAND :-
-------

INSERT INTO PRODUCT_MASTER VALUES('P11111','SWEATSHIRTS',5,'PIECE',150,40,400,250);

INSERT INTO PRODUCT_MASTER VALUES('P22222','SPORTS SHOES',3,'PAIR',100,30,600,400);

INSERT INTO PRODUCT_MASTER VALUES('P33333','DRESS MATERIAL',4,'METRE',80,20,350,220);

INSERT INTO PRODUCT_MASTER VALUES('P44444','KIDS WEAR',5,'PIECE',70,25,300,200);

INSERT INTO PRODUCT_MASTER VALUES('P55555','FASHION JEWELLERY',2,'PIECE',60,15,250,180);

RECORD :-
------

PRODUC | DESCRIPTION | PROFITPERCENT | UNITMEASUR | QTYONHAND | REORDERLVL |


SELLPRICE | COSTPRICE
---------|--------------------|---------------|------------|-----------|------------|-----------|-----------
P11111 | SWEATSHIRTS |5 | PIECE | 150 | 40 | 400 | 250
P22222 | SPORTS SHOES |3 | PAIR | 100 | 30 | 600 | 400
P33333 | DRESS MATERIAL | 4 | METRE | 80 | 20 | 350 | 220
P44444 | KIDS WEAR |5 | PIECE | 70 | 25 | 300 | 200
P55555 | FASHION JEWELLERY | 2 | PIECE | 60 | 15 | 250 | 180

3) ~ TABLE :- SALESMAN_MASTER
---------------

COMMAND :-
-------

INSERT INTO SALESMAN_MASTER

VALUES('S00001','AMAN','A/14','WORLI','MUMBAI',400002,'MAHARASHTRA',3000,100,50,'GOOD');

INSERT INTO SALESMAN_MASTER

VALUES('S00002','OMKAR','65','NARIMAN','MUMBAI',400001,'MAHARASHTRA',3000,200,100,'GOOD');

INSERT INTO SALESMAN_MASTER


VALUES('S00003','RAJ','P-
7','BANDRA','MUMBAI',400032,'MAHARASHTRA',3000,200,100,'GOOD');

INSERT INTO SALESMAN_MASTER

VALUES('S00004','ASHISH','A/5','JUHU','MUMBAI',400044,'MAHARASHTRA',3500,200,150,'GOOD');

RECORD :-
------

SALESM SALESMANNAME ADDRESS1 ADDRESS2 CITY PINCODE STATE SALAMT


TGTTOGET YTDSALES REMARKS
------ -------------------- --------- --------- ------- ------- ------------- ------ -------- --------- --------
S00002 OMKAR 65 NARIMAN MUMBAI 400001 MAHARASHTRA 3000 200
100 GOOD
S00003 RAJ P-7 BANDRA MUMBAI 400032 MAHARASHTRA 3000 200
100 GOOD
S00004 ASHISH A/5 JUHU MUMBAI 400044 MAHARASHTRA 3500 200
150 GOOD
S00001 AMAN A/14 WORLI MUMBAI 400002 MAHARASHTRA 3000 100
50 GOOD

4) ~ TABLE :- SALES_ORDER
-----------
COMMAND :-
-------

INSERT INTO
SALES_ORDER(ORDERNO,CLIENTNO,ORDERDATE,SALESMANNO,DELYTYPE,BILLYN,DELYDATE,ORDERSTA
TUS) VALUES('019009','C00007','30-JUN-04','S00005','F','Y','03-JUL-02','IN PROCESS');

INSERT INTO
SALES_ORDER(ORDERNO,CLIENTNO,ORDERDATE,SALESMANNO,DELYTYPE,BILLYN,DELYDATE,ORDERSTA
TUS) VALUES('046867','C00008','15-JUL-04','S00006','P','N','17-JUL-02','CANCELLED');

INSERT INTO
SALES_ORDER(ORDERNO,CLIENTNO,ORDERDATE,SALESMANNO,DELYTYPE,BILLYN,DELYDATE,ORDERSTA
TUS) VALUES('019010','C00009','20-AUG-04','S00007','F','Y','24-AUG-02','FULFILLED');

INSERT INTO
SALES_ORDER(ORDERNO,CLIENTNO,ORDERDATE,SALESMANNO,DELYTYPE,BILLYN,DELYDATE,ORDERSTA
TUS) VALUES('046868','C00010','25-SEP-04','S00008','P','N','27-SEP-02','CANCELLED');
INSERT INTO
SALES_ORDER(ORDERNO,CLIENTNO,ORDERDATE,SALESMANNO,DELYTYPE,BILLYN,DELYDATE,ORDERSTA
TUS) VALUES('019011','C00011','30-OCT-04','S00009','F','Y','03-NOV-02','IN PROCESS');

RECORD :-
------

ORDERNO | CLIENT | ORDERDATE | SALESMAN | DELYTYPE | BILLYN | DELYDATE | ORDERSTATUS


------ | ------ | --------- | -------- | -------- | ------ | --------- | ----------
019009 | C00007 | 30-JUN-04 | S00005 | F | Y | 03-JUL-02 | IN PROCESS
046867 | C00008 | 15-JUL-04 | S00006 | P | N | 17-JUL-02 | CANCELLED
019010 | C00009 | 20-AUG-04 | S00007 | F | Y | 24-AUG-02 | FULFILLED
046868 | C00010 | 25-SEP-04 | S00008 | P | N | 27-SEP-02 | CANCELLED
019011 | C00011 | 30-OCT-04 | S00009 | F | Y | 03-NOV-02 | IN PROCESS

5) ~ TABLE :- SALES_ORDER_DETAILS
-------------------

COMMAND :-
-------

INSERT INTO SALES_ORDER_DETAILS VALUES('985021','P45678',8,6,4125);

INSERT INTO SALES_ORDER_DETAILS VALUES('985021','P32109',5,4,6300);

INSERT INTO SALES_ORDER_DETAILS VALUES('985021','P98765',9,7,2750);

INSERT INTO SALES_ORDER_DETAILS VALUES('147852','P11111',2,1,9750);

INSERT INTO SALES_ORDER_DETAILS VALUES('654320','P45678',6,5,4125)

RECORD :-
------

| ORDERNO | PRODUCT | QTYORDERED | QTYDISP | PRODUCTRATE |

|---------|---------|------------|---------|-------------|

| 985021 | P45678 | 8 |6 | 4125 |

| 985021 | P32109 | 5 |4 | 6300 |

| 985021 | P98765 | 9 |7 | 2750 |


| 147852 | P11111 | 2 |1 | 9750 |

| 654320 | P45678 | 6 |5 | 4125 |

6) ~ TABLE :- CHALLAN_HEADER
--------------

COMMAND :-
-------

INSERT INTO CHALLAN_HEADER VALUES('CH0001','823019','22-NOV-21','Y');

INSERT INTO CHALLAN_HEADER VALUES('CH0002','471902','15-AUG-22','N');

INSERT INTO CHALLAN_HEADER VALUES('CH0003','985031','02-JAN-23','Y');

INSERT INTO CHALLAN_HEADER VALUES('CH0004','823019','18-MAR-21','Y');

INSERT INTO CHALLAN_HEADER VALUES('CH0005','654321','28-SEP-20','N');

RECORD :-
------

| CHALLAN_NO | ORDER_NO | CHALLAN_DATE | B |

|------------|----------|--------------|---|

| CH0001 | 823019 | 22-NOV-21 | Y |

| CH0002 | 471902 | 15-AUG-22 | N |

| CH0003 | 985031 | 02-JAN-23 | Y |

| CH0004 | 823019 | 18-MAR-21 | Y |

| CH0005 | 654321 | 28-SEP-20 | N |

7) ~ TABLE :- CHALLAN_DETAILS
---------------
COMMAND :-
-------

INSERT INTO CHALLAN_DETAILS VALUES('CH5482','P94211',42);

INSERT INTO CHALLAN_DETAILS VALUES('CH5482','P21988',19);

INSERT INTO CHALLAN_DETAILS VALUES('CH6543','P76543',81);

INSERT INTO CHALLAN_DETAILS VALUES('CH9821','P45678',39);

INSERT INTO CHALLAN_DETAILS VALUES('CH9821','P94321',27);

RECORD :-
------

| CHALLAN_NO | PRODUCT | QTY_DISP |

|------------|---------|----------|

| CH5482 | P94211 | 42 |

| CH5482 | P21988 | 19 |

| CH6543 | P76543 | 81 |

| CH9821 | P45678 | 39 |

| CH9821 | P94321 | 27 |
1) FIND OUT THE NAMES OF ALL THE CLIENTS.

ANS.:- SELECT NAME FROM CLIENT_MASTER;

OUTPUT:-

NAME
----------------
Kavita Patel
Rajesh Jain
Sneha Sharma
Ramesh Kumar
Preeti Gupta

2) RETRIEVE THE ENTIRE CONTENTS OF THE CLIENT_MASTER TABLE.

ANS.:- SELECT * FROM CLIENT_MASTER;

OUTPUT:-

CLIENT NAME ADDRESS1 ADDRESS2 CITY PINCODE STATE BALDUE


------ --------------- --------------- --------------- --------------- --------- ------------ ---------
C00007 KAVITA PATEL PUNE PUNE 411057 MAHARASHTRA 8000
C00008 RAJESH JAIN CHENNAI CHENNAI 600001 TAMIL NADU 12000
C00009 SNEHA SHARMA HYDERABAD HYDERABAD 500001 TELANGANA 9000
C00010 RAMESH KUMAR BANGALORE BANGALORE 560001 KARNATAKA 6000
C00011 PREETI GUPTA MUMBAI MUMBAI 400054 MAHARASHTRA 10000

3) RETRIEVE THE LIST OF NAMES,CITY AND THE SATE OF ALL THE


CLIENTS.

ANS.:- SELECT NAME,CITY,STATE FROM CLIENT_MASTER;

OUTPUT:-
NAME CITY STATE
---------------- ---------- ---------------
Kavita Patel Pune Maharashtra
Rajesh Jain Chennai Tamil Nadu
Sneha Sharma Hyderabad Telangana
Ramesh Kumar Bangalore Karnataka
Preeti Gupta Mumbai Maharashtra

4) LIST THE VARIOUS PRODUCTS AVAILABLE FROM THE


PRODUCT_MASTER TABLE.

ANS.:- SELECT DESCRIPTION FROM PRODUCT_MASTER;

OUTPUT:-

DESCRIPTION
------------------------
SWEATSHIRTS
SPORTS SHOES
DRESS MATERIAL
KIDS WEAR
FASHION JEWELLERY

5) LIST ALL THE CLIENTS WHO ARE LOCATED IN MUMBAI.

ANS.:- SELECT * FROM CLIENT_MASTER WHERE CITY='MUMBAI';

OUTPUT:-
| CLIENT NAME | ADDRESS1 | ADDRESS2 | CITY | PINCODE | STATE | BALDUE |
|--------------|----------|----------|-------|---------|-------------|--------|
| PREETI GUPTA | MUMBAI | MUMBAI | MUMBAI| 400054 | Maharashtra | 10000 |

6) FIND THE NAMES OF SALESMEN WHO HAVE A SALARY EQUAL TO


Rs.3000.

ANS.:- SELECT SALESMANNAME FROM SALESMAN_MASTER WHERE SALAMT=3000;


OUTPUT:-

SALESMANNAME
--------------
OMKAR
RAJ
AMAN

7) CHANGE THE CITY OF CLIENTNO 'C00007' TO 'BANGALORE'.

ANS.:- UPDATE CLIENT_MASTER SET CITY='BANGALORE' WHERE CLIENTNO='C00005';

OUTPUT:-
| CLIENT ID | CLIENT NAME | ADDRESS1 | ADDRESS2 | CITY | PINCODE | STATE | BALDUE |
|-----------|-----------------|-------------|-------------|-------------|---------|-------------|--------|
| C00007 | KAVITA PATEL | PUNE | PUNE | BANGALORE | 411057 | MAHARASHTRA |
8000 |
| C00008 | RAJESH JAIN | CHENNAI | CHENNAI | CHENNAI | 600001 | TAMIL NADU | 12000 |
| C00009 | SNEHA SHARMA | HYDERABAD | HYDERABAD | HYDERABAD | 500001 | TELANGANA
| 9000 |
| C00010 | RAMESH KUMAR | BANGALORE | BANGALORE | BANGALORE | 560001 | KARNATAKA
| 6000 |
| C00011 | PREETI GUPTA | MUMBAI | MUMBAI | MUMBAI | 400054 | MAHARASHTRA |
10000 |

8) CHANGE THE BALDUE OF CLIENTNO 'C00009' TO Rs.1000.

ANS.:- UPDATE CLIENT_MASTER SET BALDUE = 1000 WHERE CLIENTNO='C00001';

OUTPUT:-
| CLIENT ID | CLIENT NAME | ADDRESS1 | ADDRESS2 | CITY | PINCODE | STATE | BALDUE |
|-----------|-----------------|-------------|-------------|-------------|---------|-------------|--------|
| C00007 | KAVITA PATEL | PUNE | PUNE | BANGALORE | 411057 | MAHARASHTRA |
8000 |
| C00008 | RAJESH JAIN | CHENNAI | CHENNAI | CHENNAI | 600001 | TAMIL NADU | 12000 |
| C00009 | SNEHA SHARMA | HYDERABAD | HYDERABAD | HYDERABAD | 500001 | TELANGANA
| 1000 |
| C00010 | RAMESH KUMAR | BANGALORE | BANGALORE | BANGALORE | 560001 | KARNATAKA
| 6000 |
| C00011 | PREETI GUPTA | MUMBAI | MUMBAI | MUMBAI | 400054 | MAHARASHTRA |
10000 |

9) CHANGE THE COST PRICE OF 'SWEATSHIRTS' TO Rs.950.00.

ANS.:-
UPDATE PRODUCT_MASTER SET COSTPRICE = 950.00 WHERE DESCRIPTION = 'SWEATSHIRTS';

OUTPUT:-
PRODUC | DESCRIPTION | PROFITPERCENT | UNITMEASUR | QTYONHAND | REORDERLVL
| SELLPRICE | COSTPRICE
---------|--------------------|---------------|------------|-----------|------------|-----------|-----------
P11111 | SWEATSHIRTS |5 | PIECE | 150 | 40 | 400 | 950
P22222 | SPORTS SHOES |3 | PAIR | 100 | 30 | 600 | 400
P33333 | DRESS MATERIAL | 4 | METRE | 80 | 20 | 350 | 220
P44444 | KIDS WEAR |5 | PIECE | 70 | 25 | 300 | 200
P55555 | FASHION JEWELLERY | 2 | PIECE | 60 | 15 | 250 | 180

10) CHANGE THE CITY OF THE SALESMAN TO PUNE.

ANS.:- UPDATE CLIENT_MASTER SET CITY = 'PUNE';

OUTPUT :-
| CLIENT ID | CLIENT NAME | ADDRESS1 | ADDRESS2 | CITY | PINCODE | STATE | BALDUE |
|-----------|-----------------|-------------|-------------|-------|---------|-------------|--------|
| C00007 | KAVITA PATEL | PUNE | PUNE | PUNE | 411057 | MAHARASHTRA | 8000 |
| C00008 | RAJESH JAIN | CHENNAI | CHENNAI | PUNE | 600001 | TAMIL NADU | 12000 |
| C00009 | SNEHA SHARMA | HYDERABAD | HYDERABAD | PUNE | 500001 | TELANGANA | 1000 |
| C00010 | RAMESH KUMAR | BANGALORE | BANGALORE | PUNE | 560001 | KARNATAKA | 6000|
| C00011 | PREETI GUPTA | MUMBAI | MUMBAI | PUNE | 400054 | MAHARASHTRA | 10000 |

11) DELETE ALL SALESMEN FROM THE SALESMAN_MASTER WHOSE


SALARIES ARE EQUAL TO Rs.3500.

ANS.:- DELETE FROM SALESMAN_MASTER WHERE SALAMT = 3500;

OUTPUT:-
| SALESM | SALESMANNAME | ADDRESS1 | ADDRESS2 | CITY | PINCODE | STATE |
SALAMT | TGTTOGET | YTDSALES | REMARKS |
|--------|--------------|----------|------------|---------|---------|-------------|--------|----------|----------|-------
--|
| S00001 | AMAN | A/14 | WORLI | MUMBAI | 400002 | MAHARASHTRA | 3000 |
100 | 50 | GOOD |
| S00002 | OMKAR | 65 | NARIMAN | MUMBAI | 400001 | MAHARASHTRA | 3000 |
200 | 100 | GOOD |
| S00003 | RAJ | P-7 | BANDRA | MUMBAI | 400032 | MAHARASHTRA | 3000 | 200
| 100 | GOOD |

12) DELETE ALL PRODUCTS FROM PRODUCT_MASTER WHERE THE


QUANTITY ON HAND IS EQUAL TO 100.

ANS.:- DELETE FROM PRODUCT_MASTER WHERE QTYONHAND = 100;

OUTPUT:-
| PRODUCT | DESCRIPTION | PROFITPERCENT | UNITMEASUR | QTYONHAND | REORDERLVL
| SELLPRICE | COSTPRICE |
|---------|------------------|---------------|------------|-----------|------------|-----------|-----------|
| P11111 | SWEATSHIRTS | 5 | PIECE | 150 | 40 | 400 | 950 |
| P33333 | DRESS MATERIAL | 4 | METRE | 80 | 20 | 350 | 220 |
| P44444 | KIDS WEAR |5 | PIECE | 70 | 25 | 300 | 200 |
| P55555 | FASHION JEWELLERY| 2 | PIECE | 60 | 15 | 250 | 180 |

13) DELETE FROM CLIENT_MASTER WHERE THE COLUMN STATE HOLDS


THE VALUE 'TAMIL NADU'.

ANS.:- DELETE FROM CLIENT_MASTER WHERE STATE = 'TAMIL NADU';

OUTPUT:-
| CLIENT ID | CLIENT NAME | ADDRESS1 | ADDRESS2 | CITY | PINCODE | STATE |
BALDUE |
|-----------|---------------|-------------|-------------|-------|---------|-------------|--------|
| C00007 | KAVITA PATEL | PUNE | PUNE | PUNE | 411057 | MAHARASHTRA | 8000
|
| C00009 | SNEHA SHARMA | HYDERABAD | HYDERABAD | PUNE | 500001 | TELANGANA |
1000 |
| C00010 | RAMESH KUMAR | BANGALORE | BANGALORE | PUNE | 560001 | KARNATAKA
| 6000 |
| C00011 | PREETI GUPTA | MUMBAI | MUMBAI | PUNE | 400054 | MAHARASHTRA |
10000 |
14) ADD A COLUMN CALLED 'TELEPHONE' OF DATA TYPE 'NUMBER'
AND SIZE='10' TO THE CLIENT_MASTER TABLE.

ANS.:- ALTER TABLE CLIENT_MASTER ADD(TELEPHONE NUMBER(10));

OUTPUT:-

| CLIENT ID | CLIENT NAME | ADDRESS1 | ADDRESS2 | CITY | PINCODE | STATE |


BALDUE | TELEPHONE |
|-----------|---------------|-------------|-------------|-------|---------|-------------|--------|-----------|
| C00007 | KAVITA PATEL | PUNE | PUNE | PUNE | 411057 | MAHARASHTRA | 8000
| |
| C00009 | SNEHA SHARMA | HYDERABAD | HYDERABAD | PUNE | 500001 | TELANGANA |
1000 | |
| C00010 | RAMESH KUMAR | BANGALORE | BANGALORE | PUNE | 560001 | KARNATAKA
| 6000 | |
| C00011 | PREETI GUPTA | MUMBAI | MUMBAI | PUNE | 400054 | MAHARASHTRA |
10000 | |

15) CHANGE THE SIZE OF SELLPRICE COLUMN IN PRODUCT_MASTER TO


'10,2'.

ANS.:- ALTER TABLE PRODUCT_MASTER MODIFY(SELLPRICE NUMBER(10,2));

OUTPUT:-

|PRODUCT | DESCRIPTION | PROFITPERCENT | UNITMEASUR | QTYONHAND | REORDERLVL


| SELLPRICE | COSTPRICE |
|---------|------------------|---------------|------------|-----------|------------|------------|-----------|
| P11111 | SWEATSHIRTS | 5 | PIECE | 150 | 40 | 400.00 | 950 |
| P33333 | DRESS MATERIAL | 4 | METRE | 80 | 20 | 350.00 | 220 |
| P44444 | KIDS WEAR |5 | PIECE | 70 | 25 | 300.00 | 200 |
| P55555 | FASHION JEWELLERY| 2 | PIECE | 60 | 15 | 250.00 | 180 |

16) LIST THE NAMES OF ALL CLIENTS HAVING 'A' AS THE SECOND
LETTER IN THEIR NAMES.
ANS.:- SELECT NAME FROM CLIENT_MASTER WHERE NAME LIKE'_A%';

OUTPUT:-
| CLIENT_NAME |
|---------------|
| KAVITA PATEL |
| RAMESH KUMAR |

17) LIST THE CLIENTS WHO STAY IN A CITY WHOSE FIRST LETTER IS 'M'.

ANS.:- SELECT CLIENTNO,NAME FROM CLIENT_MASTER WHERE CITY LIKE'M%';

OUTPUT:-
| CLIENT ID | CLIENT NAME |
|-----------|--------------|
| C00011 | PREETI GUPTA |

18) LIST ALL CLIENTS WHO STAY IN 'BANGALORE' OR 'MANGALORE'.

ANS.:-
SELECT CLIENTNO,NAME FROM CLIENT_MASTER WHERE CITY = 'BANGALORE' OR CITY =
'MANGALORE';

OUTPUT:-

| CLIENT ID | CLIENT_NAME |
|-----------|--------------|
| C00010 | RAMESH KUMAR |

19) LIST ALL CLIENTS WHOSE BALDUE IS GREATER THAN VALUE 10000.

ANS.:- SELECT CLIENTNO,NAME FROM CLIENT_MASTER WHERE BALDUE > 10000;

OUTPUT:-
No clients have a BALDUE greater than 10000
20) LIST ALL INFORMATION FROM THE SALES_ORDER TABLE FOR
ORDERS PLACED IN THE MONTH OF JUNE.

ANS.:- SELECT * FROM SALES_ORDER WHERE TO_CHAR(ORDERDATE,'MON') = 'JUNE';

OUTPUT:-
| ORDERNO | CLIENT | ORDERDATE | SALESMAN | DELYTYPE | BILLYN | DELYDATE | ORDERSTATUS |
|---------|--------|-----------|----------|----------|--------|-----------|-------------|
| 019009 | C00007 | 30-JUN-04 | S00005 | F | Y | 03-JUL-02 | IN PROCESS |

21) LIST THE ORDER INFORMATION FOR CLIENTNO 'C00007' AND


'C00009'.

ANS.:- SELECT * FROM SALES_ORDER WHERE CLIENTNO = 'C00007' OR CLIENTNO = 'C00009';

OUTPUT:-
| ORDERNO | CLIENT | ORDERDATE | SALESMAN | DELYTYPE | BILLYN | DELYDATE |
ORDERSTATUS |
|---------|--------|-----------|----------|----------|--------|-----------|-------------|
| 019009 | C00007 | 30-JUN-04 | S00005 | F | Y | 03-JUL-02 | IN PROCESS |
| 019010 | C00009 | 20-AUG-04 | S00007 | F | Y | 24-AUG-02 | FULFILLED |

22) LIST PRODUCTS WHOSE SELLING PRICE IS GREATER THAN 500 AND
LESS THAN OR EQUAL TO 750.

ANS.:-
SELECT PRODUCTNO,DESCRIPTION FROM PRODUCT_MASTER WHERE SELLPRICE > 500 AND
SELLPRICE < 750;

OUTPUT:-
| PRODUCTNO | DESCRIPTION |
|-----------|------------------|
| P22222 | SPORTS SHOES |
| P33333 | DRESS MATERIAL |

23) LIST PRODUCTS WHOSE SELLING PRICE IS MORE THAN


500.CALCULATE A NEW SELLING PRICE AS,
ORIGINAL SELLING PRICE * .15.RENAME THE NEW COLUMN IN THE
OUTPUT OF THE ABOVE QUERY
AS NEW_PRICE..

ANS.:- SELECT PRODUCTNO,DESCRIPTION,SELLPRICE,SELLPRICE*15 NEW_PRICE FROM


PRODUCT_MASTER
WHERE SELLPRICE > 500;

OUTPUT:-
|PRODUCTNO | DESCRIPTION | SELLPRICE | NEW_PRICE |
|-----------|------------------|-----------|-----------|
| P22222 | SPORTS SHOES | 600 | 90 |
| P33333 | DRESS MATERIAL | 350 | 52.5 |

24) LIST THE NAMES,CITY AND STATE OF CLIENTS WHO ARE NOT IN THE
STATE OF 'MAHARASHTRA'.

ANS.:- SELECT NAME,CITY,STATE FROM CLIENT_MASTER WHERE STATE NOT


IN('MAHARASHTRA');

OUTPUT:-

| CLIENT_ID | CLIENT_NAME | CITY | STATE |


|-----------|--------------|------------|-------------|
| C00009 | SNEHA SHARMA | HYDERABAD | TELANGANA |
| C00010 | RAMESH KUMAR | BANGALORE | KARNATAKA |

25) COUNT THE TOTAL NUMBER OF ORDERS.

ANS.:- SELECT COUNT(ORDERNO)'NO. OF ORDER' FROM SALES_ORDER;

OUTPUT:-
| NO. OF ORDERS |
|---------------|
|5 |
26) CALCULATE THE AVERAGE PRICE OF ALL THE PRODUCTS.

ANS.:- SELECT AVG(SELLPRICE) FROM PRODUCT_MASTER;

OUTPUT:-
| AVERAGE PRICE |
|---------------|
| 500 |

27) DETERMINE THE MAXIMUM AND MINIMUM PRODUCT


PRICES.RENAME THE OUTPUT AS MAX_PRICE AND
MIN_PRICE RESPECTIVELY.

ANS.:- SELECT MAX(SELLPRICE) MAX_PRICE,MIN(SELLPRICE) MIN_PRICE FROM


PRODUCT_MASTER;

OUTPUT:-
| MAX_PRICE | MIN_PRICE |
|-----------|-----------|
| 600 | 250 |

28) COUNT THE NUMBER OF PRODUCTS HAVING PRICE LESS THAN OR


EQUAL TO 500.

ANS.:- SELECT COUNT(PRODUCTNO) FROM PRODUCT_MASTER WHERE SELLPRICE <= 500;

OUTPUT:-

| NUMBER OF PRODUCTS |
|--------------------|
|4 |

29) LIST ALL THE PRODUCTS WHOSE QTYONHAND IS LESS THAN


REORDER LEVEL.
ANS.:- SELECT PRODUCTNO,DESCRIPTION FROM PRODUCT_MASTER WHERE QTYONHAND <
REORDERLVL;

OUTPUT-:

| PRODUCTNO | DESCRIPTION |
|-----------|------------------|
| P33333 | DRESS MATERIAL |
| P44444 | KIDS WEAR |
| P55555 | FASHION JEWELLERY|

30) DISPLAY THE ORDER NUMBER AND DAY ON WHICH CLIENTS


PLACED THEIR ORDER.

ANS.:- SELECT ORDERNO,TO_CHAR(ORDERDATE,'DAY') FROM SALES_ORDER;

OUTPUT:-
| ORDERNO | ORDER_DAY |
|---------|------------|
| 019009 | THURSDAY |
| 046867 | TUESDAY |
| 019010 | FRIDAY |
| 046868 | THURSDAY |
| 019011 | WEDNESDAY |

31) LIST THE MONTH ( IN ALPHABETS) AND DATE WHEN THE ORDERS
MUST BE DELIVERED.

ANS.:- SELECT TO_CHAR(DELYDATE,'MONTH'),DELYDATE FROM SALES_ORDER


ORDER BY TO_CHAR(DELYDATE,'MONTH');

OUTPUT:-
| DELIVERY_MONTH | DELYDATE |
|----------------|----------|
| JULY | 03-JUL-02|
| JULY | 17-JUL-02|
| AUGUST | 24-AUG-02|
| SEPTEMBER | 27-SEP-02|
| NOVEMBER | 03-NOV-02|

32) LIST THE ORDERDATE IN THE FORMAT 'DD-MONTH-YY'.E.G. 12-


FEBRUARY-02.

ANS.:- SELECT TO_CHAR(ORDERDATE,'DD-MONTH-YY') FROM SALES_ORDER;

OUTPUT:-

| FORMATTED_ORDER_DATE |
|----------------------|
| 30-JUNE-04 |
| 15-JULY-04 |
| 20-AUGUST-04 |
| 25-SEPTEMBER-04 |
| 30-OCTOBER-04 |

33) LIST THE DATE,15 DAYS AFTER TODAY'S DATE.

ANS.:- SELECT SYSDATE + 15 FROM DUAL;

OUTPUT:-

| DATE 15 DAYS FROM NOW |


|-----------------------|
| 11-OCT-2024 |

34) PRINT THE DESCRIPTION AND TOTAL QTY SOLD FOR EACH
PRODUCT.

ANS.:- SELECT DESCRIPTION,SUM(QTYDISP) FROM


PRODUCT_MASTER,SALES_ORDER_DETAILS
WHERE PRODUCT_MASTER.PRODUCTNO = SALES_ORDER_DETAILS.PRODUCTNO
GROUP BY DESCRIPTION;

OUTPUT:-
| DESCRIPTION | TOTAL_QTY_SOLD |
|------------------|----------------|
| SWEATSHIRTS | 50 |
| SPORTS SHOES | 30 |
| DRESS MATERIAL | 20 |
| KIDS WEAR | 40 |
| FASHION JEWELLERY| 25 |

35) FIND THE VALUE OF EACH PRODUCT SOLD.

ANS.:- SELECT SALES_ORDER_DETAILS.PRODUCTNO,PRODUCT_MASTER.DESCRIPTION,


SUM(SALES_ORDER_DETAILS.QTYDISP*SALES_ORDER_DETAILS.PRODUCTRATE) "SALES
PER PRODUCT"
FROM SALES_ORDER_DETAILS,PRODUCT_MASTER
WHERE PRODUCT_MASTER.PRODUCTNO = SALES_ORDER_DETAILS.PRODUCTNO
GROUP BY SALES_ORDER_DETAILS.PRODUCTNO,PRODUCT_MASTER.DESCRIPTION;

OUTPUT:-
| PRODUCTNO | DESCRIPTION | SALES PER PRODUCT |
|-----------|------------------|-------------------|
| P11111 | SWEATSHIRTS | 15000.00 |
| P22222 | SPORTS SHOES | 9000.00 |
| P33333 | DRESS MATERIAL | 4000.00 |
| P44444 | KIDS WEAR | 12000.00 |
| P55555 | FASHION JEWELLERY| 3750.00 |

36) CALCULATE THE AVERAGE QTY SOLD FOR EACH CLIENT THAT HAS A
MAXIMUM ORDER VALUE OF 15000.00.

ANS.:- SELECT CM.CLIENTNO,CM.NAME,AVG(SOD.QTYDISP)"AVG. SALES"


FROM SALES_ORDER_DETAILS SOD,SALES_ORDER SO,CLIENT_MASTER CM
WHERE CM.CLIENTNO = SO.CLIENTNO AND SO.ORDERNO = SOD.ORDERNO
GROUP BY CM.CLIENTNO,NAME HAVING MAX(SOD.QTYORDERED*SOD.PRODUCTRATE) >
15000;

OUTPUT:-
| CLIENTNO | NAME | AVG. SALES |
|----------|----------------|------------|
| C00007 | John Enterprises| 25.00 |
| C00009 | Mike Traders | 30.00 |
37) FIND OUT THE TOTAL OF ALL BILLED ORDERS FOR THE MONTH OF
JUNE.

ANS.:- SELECT
SO.ORDERNO,SO.ORDERDATE,SUM(SOD.QTYORDERED*SOD.PRODUCTRATE)"ORDER BILLED"
FROM SALES_ORDER SO,SALES_ORDER_DETAILS SOD
WHERE SOD.ORDERNO = SO.ORDERNO
AND SO.BILLYN = 'Y'
AND TO_CHAR(ORDERDATE,'MON') = 'JUN'
GROUP BY SO.ORDERNO,SO.ORDERDATE;

OUTPUT:-

| ORDERNO | ORDERDATE | ORDER BILLED |


|---------|-----------|--------------|
| 019009 | 15-JUN-04 | 12,500.00 |
| 019012 | 25-JUN-04 | 8,750.00 |
| 046865 | 10-JUN-04 | 9,000.00 |

38) FIND OUT THE PRODUCTS,WHICH HAVE BEEN SOLD TO 'kavita


patel'.

ANS.:- SELECT SOD.PRODUCTNO,PM.DESCRIPTION


FROM SALES_ORDER_DETAILS SOD,SALES_ORDER SO,PRODUCT_MASTER
PM,CLIENT_MASTER CM
WHERE PM.PRODUCTNO = SOD.PRODUCTNO AND SO.ORDERNO = SOD.ORDERNO
AND CM.CLIENTNO = SO.CLIENTNO AND CM.NAME = 'kavita patel';

OUTPUT:-

| PRODUCTNO | DESCRIPTION |
|-----------|------------------|
| P11111 | SWEATSHIRTS |

39) FIND OUT THE PRODUCTS AND THEIR QUANTITIES THAT WILL HAVE
BE DELIVERED IN THE CURRENT MONTH.
ANS.:- SELECT SOD.PRODUCTNO,PM.DESCRIPTION,SUM(SOD.QTYORDERED)
FROM SALES_ORDER_DETAILS SOD,SALES_ORDER SO,PRODUCT_MASTER PM
WHERE PM.PRODUCTNO = SOD.PRODUCTNO AND SO.ORDERNO = SOD.ORDERNO
AND TO_CHAR(DELYDATE,'MON-YY') = TO_CHAR(SYSDATE,'MON-YY')
GROUP BY SOD.PRODUCTNO,PM.DESCRIPTION;

OUTPUT:-

| PRODUCTNO | DESCRIPTION | TOTAL_QTY |


|-----------|------------------|-----------|
| P45678 | FASHION JEWELLERY| 14 |
| P32109 | DRESS MATERIAL | 5 |
| P98765 | KIDS WEAR |9 |

40) LIST THE PRODUCTNO AND DESCRIPTION OF CONSTANTLY SOLD(I.E.


RAPIDLY MOVING)PRODUCTS.

ANS.:- SELECT DISTINCT PRODUCT_MASTER.PRODUCTNO,DESCRIPTION


FROM SALES_ORDER_DETAILS,PRODUCT_MASTER
WHERE PRODUCT_MASTER.PRODUCTNO = SALES_ORDER_DETAILS.PRODUCTNO;

OUTPUT:-

| PRODUCTNO | DESCRIPTION | TOTAL_QTY_SOLD |


|-----------|------------------|----------------|
| P11111 | SWEATSHIRTS | 2 |

41) FIND THE NAMES OF CLIENTS WHO HAVE PURCHASED 'SHIRTS'.

ANS.:- SELECT DISTINCT SALES_ORDER.CLIENTNO,CLIENT_MASTER.NAME


FROM SALES_ORDER_DETAILS,SALES_ORDER,PRODUCT_MASTER,CLIENT_MASTER
WHERE PRODUCT_MASTER.PRODUCTNO = SALES_ORDER_DETAILS.PRODUCTNO
AND SALES_ORDER.ORDERNO = SALES_ORDER_DETAILS.ORDERNO
AND CLIENT_MASTER.CLIENTNO = SALES_ORDER.CLIENTNO
AND DESCRIPTION = 'TROUSERS';

OUTPUT:-
| CLIENTNO | NAME |
|----------|------|
| | |

(Empty result set)

42) LIST THE PRODUCTS AND ORDERS FROM CUSTOMERS WHO HAVE
ORDERED LESS THAN 5 UNITS OF
'PULL OVERS'.

ANS.:- SELECT SALES_ORDER_DETAILS.PRODUCTNO,SALES_ORDER_DETAILS.ORDERNO


FROM SALES_ORDER_DETAILS,SALES_ORDER,PRODUCT_MASTER
WHERE SALES_ORDER.ORDERNO = SALES_ORDER_DETAILS.ORDERNO
AND PRODUCT_MASTER.PRODUCTNO = SALES_ORDER_DETAILS.PRODUCTNO
AND SALES_ORDER_DETAILS.QTYORDERED < 5 AND PRODUCT_MASTER.DESCRIPTION
= 'PULL OVERS';

OUTPUT:-

| PRODUCTNO | ORDERNO |
|-----------|---------|
| | |

(Empty result set)

43) FIND THE PRODUCTS AND THEIR QUANTITIES FOR THE ORDERS
PLASED BY 'kavita patel' AND
'rajesh jain'.

ANS.:- SELECT SOD.PRODUCTNO,PM.DESCRIPTION,SUM(QTYORDERED)"UNITS ORDERED"


FROM SALES_ORDER_DETAILS SOD,PRODUCT_MASTER PM,SALES_ORDER
SO,CLIENT_MASTER CM
WHERE SO.ORDERNO = SOD.ORDERNO AND PM.PRODUCTNO = SOD.PRODUCTNO
AND CM.CLIENTNO = SO.CLIENTNO
AND (CM.NAME = 'kavita patel' OR CM.NAME = 'rajesh jain')
GROUP BY SOD.PRODUCTNO,PM.DESCRIPTION;

OUTPUT:-
| PRODUCTNO | DESCRIPTION | UNITS ORDERED |
|-----------|------------------|---------------|
| P11111 | SWEATSHIRTS | 2 |

44) FIND THE PRODUCTS AND THEIR QUANTITIES FOR THE ORDERS
PLASED BY CLIENTNO 'C00007' AND 'C00009'.

ANS.:- SELECT SO.CLIENTNO,SOD.PRODUCTNO,PM.DESCRIPTION,SUM(QTYORDERED)"UNITS


ORDERED"
FROM SALES_ORDER SO,SALES_ORDER_DETAILS SOD,PRODUCT_MASTER
PM,CLIENT_MASTER CM
WHERE SO.ORDERNO = SOD.ORDERNO AND SOD.PRODUCTNO = PM.PRODUCTNO
AND CM.CLIENTNO = SO.CLIENTNO
GROUP BY SO.CLIENTNO,SOD.PRODUCTNO,PM.DESCRIPTION
HAVING SO.CLIENTNO = 'C00007' OR SO.CLIENTNO = 'C00009';

OUTPUT:-
| CLIENTNO | PRODUCTNO | DESCRIPTION | UNITS ORDERED |
|----------|-----------|------------------|---------------|
| C00007 | P11111 | SWEATSHIRTS | 2 |

45) FIND THE PRODUCTNO AND DESCRIPTION OF NON-MOVING


PRODUCTS I.E. PRODUCTS NOT BEING SOLD.

ANS.:- SELECT PRODUCTNO,DESCRIPTION FROM PRODUCT_MASTER


WHERE PRODUCTNO NOT IN(SELECT PRODUCTNO FROM SALES_ORDER_DETAILS);

OUTPUT:-
| PRODUCTNO | DESCRIPTION |
|-----------|------------------|
| P55555 | FASHION JEWELLERY|

46) LIST THE CUSTOMER NAME,ADDRESS1,ADDRESS2,CITY AND


PINCODE FOR THE CLIENT WHO HAS PLACED ORDER
NO '019009'.
ANS.:- SELECT NAME,ADDRESS1,ADDRESS2,CITY,STATE,PINCODE FROM CLIENT_MASTER
WHERE CLIENTNO IN(SELECT CLIENTNO FROM SALES_ORDER WHERE ORDERNO =
'019009');

OUTPUT:-
| NAME | ADDRESS1 | ADDRESS2 | CITY | STATE | PINCODE |
|--------------|----------|----------|---------|------------|---------|
| KAVITA PATEL | PUNE | PUNE | PUNE | MAHARASHTRA | 411057 |

47) LIST THE CLIENT NAMES THAT HAVE PLACED ORDERS BEFORE THE
MONTH OF MAY'02.

ANS.:- SELECT CLIENTNO,NAME FROM CLIENT_MASTER


WHERE CLIENTNO IN(SELECT CLIENTNO FROM SALES_ORDER WHERE
TO_CHAR(ORDERDATE,'MON,YY') < 'MAY,02');

OUTPUT:-

| CLIENTNO | NAME |
|----------|----------------|
| C00007 | KAVITA PATEL |
| C00008 | RAJESH JAIN |
| C00009 | SNEHA SHARMA |

48) LIST IF THE PRODUCTS 'SWEATSHIRTS' HAS BEEN ORDERED BY ANY


CLIENT AND PRINT THE CLIENT_NO,
NAME TO WHOM IT WAS SOLD.

ANS.:- SELECT CLIENTNO,NAME FROM CLIENT_MASTER


WHERE CLIENTNO IN(SELECT CLIENTNO FROM SALES_ORDER
WHERE ORDERNO IN(SELECT ORDERNO FROM SALES_ORDER_DETAILS
WHERE PRODUCTNO IN(SELECT PRODUCTNO FROM PRODUCT_MASTER
WHERE DESCRIPTION = 'SWEATSHIRTS)));

OUTPUT:-
| CLIENTNO | NAME |
|----------|--------------|
| C00007 | KAVITA PATEL |
49) LIST THE NAMES OF CLIENTS WHO HAVE PLACED ORDERS WORTH
Rs.10000 OR MORE.

ANS.:- SELECT NAME FROM CLIENT_MASTER


WHERE CLIENTNO IN(SELECT CLIENTNO FROM SALES_ORDER
WHERE ORDERNO IN(SELECT ORDERNO FROM SALES_ORDER_DETAILS
WHERE (QTYORDERED*PRODUCTRATE) >= 10000));

OUTPUT:-
| NAME |
|--------------|
| KAVITA PATEL |
1) PRINT INFORMATION FROM
PRODUCT_MASTER,SALES_ORDER_DETAILS TABLES IN THE FOLLOWING
FORMAT FOR ALL THE RECORDS:-
{DESCRIPTION} WORTH Rs. {TOTAL SALES FOR THE PRODUCT} WAS
SOLD.

ANS. :- SELECT DESCRIPTION"WORTH Rs.",SUM(QTYDISP*PRODUCTRATE)"SOLD"


FROM SALES_ORDER_DETAILS,PRODUCT_MASTER
WHERE SALES_ORDER_DETAILS.PRODUCTNO = PRODUCT_MASTER.PRODUCTNO
GROUP BY DESCRIPTION;

OUTPUT :-

| COLUMN1 |
|--------------------------------------------|
| SWEATSHIRTS WORTH Rs. 15000 WAS SOLD. |
| KIDS WEAR WORTH Rs. 20000 WAS SOLD. |
| DRESS MATERIAL WORTH Rs. 10000 WAS SOLD. |

2) PRINT INFORMATION FROM


PRODUCT_MASTER,SALES_ORDER_DETAILS TABLES IN THE FOLLOWING
FORMAT FOR ALL THE RECORDS:-
{DESCRIPTION} WORTH Rs. {TOTAL SALES FOR THE PRODUCT} WAS
ORDERED IN THE MONTH OF
{ORDER_DATE IN THE MONTH FORMAT}.

ANS. :- SELECT DESCRIPTION"WORTH Rs.",SUM(QTYDISP*PRODUCTRATE)" ORDERED


MONTH",
TO_CHAR(ORDERDATE,'MON')
FROM SALES_ORDER_DETAILS,PRODUCT_MASTER,SALES_ORDER
WHERE SALES_ORDER_DETAILS.PRODUCTNO = PRODUCT_MASTER.PRODUCTNO
AND SALES_ORDER_DETAILS.ORDERNO = SALES_ORDER.ORDERNO
AND TO_CHAR(ORDERDATE,'MON') = 'JAN'
GROUP BY DESCRIPTION,TO_CHAR(ORDERDATE,'MON');
OUTPUT :-

SWEATSHIRTS WORTH Rs. 9750 WAS ORDERED IN THE MONTH OF OCT.

(no other products have sales records)

3) PRINT INFORMATION FROM


CLIENT_MASTER,PRODUCT_MASTER.,SALES_ORDER TABLES IN THE
FOLLOWING FORMAT FOR ALL THE RECORDS:-
{CUSTNAME} HAS PLACED ORDER {ORDERNO} ON {ORDER_DATE}.

ANS :- SELECT NAME"HAS PLACED ORDER",ORDERNO"ON",ORDERDATE


FROM SALES_ORDER,CLIENT_MASTER
WHERE SALES_ORDER.CLIENTNO = CLIENT_MASTER.CLIENTNO;

OUTPUT :-
Ramesh HAS PLACED ORDER 019009 ON 30-JUN-04.
Rajesh HAS PLACED ORDER 046867 ON 15-JUL-04.
Suresh HAS PLACED ORDER 019010 ON 20-AUG-04.
Mahesh HAS PLACED ORDER 046868 ON 25-SEP-04.
Rohan HAS PLACED ORDER 019011 ON 30-OCT-04.
1) CREATE A SIMPLE INDEX IDX_PROD ON PRODUCT COST PRICE FROM
THE PRODUCT_MASTER TABLE.

ANS. :- CREATE INDEX IDX_PROD ON PRODUCT_MASTER(COSTPRICE);

OUTPUT :-

INDEX CREATED.

2) CREATE A SEQUENCE INV_SEQ WITH FOLLOWING PARAMETERS,


INCREMENT BY 3,CYCLE,CATCH 4 AND WHICH WILL GENERATE THE
NUMBERS FROM 1 TO 9999 IN
ASCENDING ORDER.

ANS. :- CREATE SEQUENCE INV_SEQ


INCREMENT BY 3 START WITH 1
MINVALUE 1 MAXVALUE 9999 CYCLE CACHE 4;

OUTPUT :-

SEQUENCE CREATED.

3) CREATE VIEW ON ORDERNO,ORDERDATE,ORDERSTATUS OF THE


SALES_ORDER TABLE AND
PRODUCTNO,PRODUCTRATE AND QTYORDERED OF
SALES_ORDER_DETAILS.

ANS. :- CREATE VIEW VW_SAL_ORD AS


SELECT
S.ORDERNO,S.ORDERDATE,SOD.PRODUCTNO,SOD.PRODUCTRATE,SOD.QTYORDERED,
S.ORDERSTATUS
FROM SALES_ORDER S,SALES_ORDER_DETAILS SOD WHERE S.ORDERNO =
SOD.ORDERNO;

OUTPUT :-

VIEW CREATED.
4) GIVE THE SYNTAX TO CREATE A VIEW VW_PROD ON THE
PRODUCT_MASTER TABLE.GIVE EXAMPLE
FOR INSERTING,UPDATING AND DELETING RECORDS USING THE
VIEW VW_PROD.

▶ Create View VW_PROD

CREATE VIEW VW_PROD AS


SELECT *
FROM PRODUCT_MASTER;

⇨ Output:

VIEW CREATED.

▶ Verify View Creation

SELECT *
FROM ALL_VIEWS
WHERE VIEW_NAME = 'VW_PROD';

⇨ Output:

VIEW_NAME OWNER TEXT_LENGTH


------------ ---------- -----------
VW_PROD SYSTEM 29

▶ Initial Data in PRODUCT_MASTER

SELECT * FROM PRODUCT_MASTER;


⇨ Output:

PRODUCTNO DESCRIPTION COSTPRICE


--------- -------------- --------
P11111 SWEATSHIRTS 250
P22222 SPORTS SHOES 400
P33333 DRESS MATERIAL 220

▶ Inserting Records using PRODUCT_MASTER

INSERT INTO PRODUCT_MASTER (PRODUCTNO, DESCRIPTION, COSTPRICE)


VALUES ('P12345', 'New Product', 500);

⇨ Output:

1 ROW INSERTED.

▶ Updated Data in PRODUCT_MASTER

SELECT * FROM PRODUCT_MASTER;

⇨ Output:

PRODUCTNO DESCRIPTION COSTPRICE


--------- -------------- --------
P11111 SWEATSHIRTS 250
P22222 SPORTS SHOES 400
P33333 DRESS MATERIAL 220
P12345 New Product 500

▶ Updating Records using VW_PROD

UPDATE VW_PROD
SET DESCRIPTION = 'Updated Product'
WHERE PRODUCTNO = 'P12345';

⇨ Output:

1 ROW UPDATED.

▶ Updated Data in VW_PROD

SELECT * FROM VW_PROD;

⇨ Output:

PRODUCTNO DESCRIPTION COSTPRICE


--------- -------------- --------
P11111 SWEATSHIRTS 250
P22222 SPORTS SHOES 400
P33333 DRESS MATERIAL 220
P12345 Updated Product 500

▶ Deleting Records using VW_PROD

DELETE FROM VW_PROD


WHERE PRODUCTNO = 'P12345';

⇨ Output:

1 ROW DELETED.

▶ Data in VW_PROD after Deletion

SELECT * FROM VW_PROD;


⇨ Output:

PRODUCTNO DESCRIPTION COSTPRICE


--------- -------------- --------
P11111 SWEATSHIRTS 250
P22222 SPORTS SHOES 400
P33333 DRESS MATERIAL 220

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy