Professional Documents
Culture Documents
7 rows selected
CREATE THE TABLE:
9 rows selected
QUERIES
NAME
--------------------
pramada
basu
ravi
rukmani
Ivan
vandana
ankit
7 rows selected.
DESCRIPTION
---------------
1.44 floppies
monitor
monitor
mouse
1.22 floppies
keyboard
cd drive
540HDD
1.44 drive
1.22 drive
10 rows selected.
4 rows selected.
5. DISPLAY INFORMATION FOR CLIENT NO 0001 AND 0002.
7. FIND ALL THE PRODUCTS WHERE SELLING PRICE IS GREATER THAN RS.
5000.
10.List the name city and state of client who not stay in state of maharastra.
1 row updated.
DELETE THE RECORD WITH CLIENT 0001 FROM THE CLIENT MASTER.
1 row deleted.
1 row updated.
1 row updated.
FIND THE PRODUCTS WHOSE SELLING PRICE IS MORE THAN 1500 AND
ALSO FIND THE NEW SELLING PRICE AS ORIGINAL SELLING PRICE *15.
FIND OUT THE CLIENT WHO STAYS IN THE CITY WHOSE SECOND LETTER
IS A.
DESCRIPTION
------------------------------
1.22 drive
1.22 floppies
1.44 Drive
1.44 floppies
540HDD
cd drive
keyboard
monitor
mouse
9 rows selected.
COUNT(DISTINCTDESCRIPTION)
--------------------------
9
MIN_PRICE MAX_PRICE
---------- ----------
500 11200
COUNT(PRODUCT_NO)
-----------------
4
ASSIGNMENT 3
(RESTRICTION ON TABLE )
Sales_master
SQL> create table sales_master11
2 ( salesman_no varchar2(6)CHECK(salesman_no LIKE 's%'),
3 sal_names varchar2(20)NOT NULL,
4 Address varchar2(20)NOT NULL,
5 city varchar2(20),
6 state varchar2(20),
7 pincode varchar2(6),
8 sal_amount number(8,2)NOT NULL,
9 tgt_to_get number(6,2)NOT NULL,
10 ytd_sales number(6,2)NOT NULL,
11 remarks varchar2(30),
12 PRIMARY KEY(salesman_no),
13 CHECK(tgt_to_get !=0),
14 CHECK(sal_amount !=0),
15 CHECK(ytd_sales!=0 ));
Table created.
Saless_order
Table created.
Table created.
Table created.
Table altered.
Table altered.
SQL> desc product_master11;
Name Null? Type
----------------------------------------- -------- --------------------
PRODUCT_NO VARCHAR2(8)
DESCRIPTION VARCHAR2(15)
PROFITPERCENT NUMBER(6)
UNITMEASURE VARCHAR2(15)
QUANTITY NUMBER(4)
REORDER NUMBER(4)
SELLPRICE NUMBER(8)
COSTPRICE NUMBER(8)
PHONE_NO NUMBER(12)
PRODUCT_NO VARCHAR2(8)
DESCRIPTION NOT NULL VARCHAR2(15)
PROFITPERCENT NOT NULL NUMBER(6)
UNITMEASURE VARCHAR2(15)
QUANTITY NUMBER(4)
REORDER NUMBER(4)
SELLPRICE NOT NULL NUMBER(8)
COSTPRICE NOT NULL NUMBER(8)
PHONE_NO NUMBER(12)
Table altered.
no rows selected
ASSIGNMENT 5
IMPLEMENT THE CONCEPT OF JOINS
FIND OUT THE PRODUCT WHICH HAS BEEN SOLD TO ‘IVAN SAYROSS.’
Select product_no,description
From product_master11
Where Item_sold_to=’Ivan Sayross’;
FIND OUT THE PRODUCT AND THEIR QUANTITIES THAT WILL HAVE DO
DELIVERED.
Select product_description,product_quantity
From product_master
Where status=’deliver’;
FIND OUT THE NAMES OF CLIENTS WHO HAVE PURCHASED ‘CD DRIVE’
Select c.name
From client_master11 c, product_master11 p
Where c.product_id=p.product_id
AND p.description =’Cd drive’;
Select p.product_no,p.s_orderno
From sales_order11 p,sales_order_detail s
Where p.product_no=s.product_no
And s.quantity<5 AND s.description =’1.44 floppies’;
FIND THE PRODUCTS AND THEIR QUANTITIES FOR THE ORDERS PLACED
BY CLIENT_NO “ C00001” AND “C00002”
Select p.product_no,p.quantities,p.description
From sales_order p,client_master c
Where p.product_no=c.itemorder-id
And c.client_no=’C000001’ OR ’C000002’;
ASSIGNMENT 6
Print the description and total quantity sold for each product.
Select description,quantity_sold
From product_master11
Order by quantity sold ASC;
Select product_no,quantity_ordered,description
From sales_order_details11
Group by product_no;
ASSIGNMENT 7
View created.
UPDATING
SQL> select * from employees11;
1 row updated.
INSERTION NOT ALLOWED
View created.
11 rows selected.
ASSIGNMENT 8
SQL> declare
2 a number(2);
3 b number(2);
4 c number(2);
5 begin
6 a:=&a;
7 b:=&b;
8 c:=a+b;
9 dbms_output.put_line(a|| ' + '||b||' = '||c);
10 end;
11 /
Enter value for a: 44
old 6: a:=&a;
new 6: a:=44;
Enter value for b: 43
old 7: b:=&b;
new 7: b:=43;
44 + 43 = 87
SQL> declare
2 a number(4);
3 begin
4 a:=&a;
5 if mod(a,2)=0 then
6 dbms_output.put_line('A is an even NUMBER');
7 else
8 dbms_output.put_line('A is an odd NUMBER');
9 end if;
10 end;
11 /
Enter value for a: 32
old 4: a:=&a;
new 4: a:=32;
A is an even NUMBER
SQL> declare
2
3 i number(4):=0;
4 j number(4):=1;
5 k number(4):=0;
6 begin
7 dbms_output.put_line(i);
8 dbms_output.put_line(j);
9 for l IN 2..8 loop
10 k:=i+j;
11 i:=j;
12 j:=k;
13 dbms_output.put_line(k);
14 end loop;
15 end;
16 /
0
1
1
2
3
5
8
13
21