Skip to content

Commit 75ebfb6

Browse files
committed
complete till 9
1 parent 7397e44 commit 75ebfb6

File tree

16 files changed

+694
-2067
lines changed

16 files changed

+694
-2067
lines changed

1.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import pandas as pd
2+
# string "Hello World"
3+
4+
for i in range(1000):
5+
print("Hello World")
6+
7+
accept
8+
# world string

all.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
with open("dbms/all.sql","w",encoding="utf-8") as f:
2+
f.write("")
3+
4+
5+
6+
for i in range(1,10):
7+
8+
if i == 5:
9+
10+
continue
11+
with open("dbms/all.sql","a",encoding="utf-8") as f:
12+
with open("dbms/" + str(i)+'.sql', 'r',encoding="utf-8") as f1:
13+
f.write(f1.read())
14+
15+
16+
# empty dbms/a.md
17+
with open("dbms/a.md","w",encoding="utf-8") as f:
18+
f.write("")
19+
20+
for i in range(2,5):
21+
22+
23+
24+
if i == 2:
25+
26+
continue
27+
with open("dbms/a.md","a",encoding="utf-8") as f:
28+
with open("dbms/" + str(i)+'t.md', 'r',encoding="utf-8") as f1:
29+
f.write(f1.read())
File renamed without changes.

dbms/10.sql

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
2+
3+
-- 1. WAP in PL/SQL for addition of two numbers.
4+
5+
sql
6+
DECLARE
7+
a INT := 10;
8+
b INT := 20;
9+
c INT;
10+
BEGIN
11+
c := a + b;
12+
DBMS_OUTPUT.PUT_LINE(c);
13+
END;
14+
15+
16+
-- 2. WAP in PL/SQL for addition of 1 to 100 numbers.
17+
18+
sql
19+
DECLARE
20+
a INT := 100;
21+
b INT := 1;
22+
c INT;
23+
BEGIN
24+
LOOP
25+
c := a + b;
26+
b := b + 1;
27+
DBMS_OUTPUT.PUT_LINE(c);
28+
EXIT WHEN b > a;
29+
END LOOP;
30+
END;
31+
32+
33+
-- 3. WAP in PL/SQL to check the given number is even or odd.
34+
35+
sql
36+
DECLARE
37+
a INT := 2;
38+
b INT := 1;
39+
c INT;
40+
BEGIN
41+
c := a % b;
42+
IF c = 0 THEN
43+
DBMS_OUTPUT.PUT_LINE('Even');
44+
ELSE
45+
DBMS_OUTPUT.PUT_LINE('Odd');
46+
END IF;
47+
END;
48+
49+
50+
-- 4. WAP in PL/SQL to inverse a number, eg. Number 5639 when inverted must be display output 9365.
51+
52+
sql
53+
DECLARE
54+
a INT := 5639;
55+
b INT := 0;
56+
c INT;
57+
BEGIN
58+
LOOP
59+
c := a % 10;
60+
b := b * 10 + c;
61+
a := a / 10;
62+
DBMS_OUTPUT.PUT_LINE(b);
63+
EXIT WHEN a = 0;
64+
END LOOP;
65+
END;
66+
67+
68+
-- 5. WAP in PL/SQL for changing the price of product ‘P00001’ to 4000 if the price is less than 4000 in product_master table. The change is recorded in the old_price_table along with product_no and the date on which the price was changed last.
69+
70+
sql
71+
DECLARE
72+
a INT := 4000;
73+
b INT;
74+
c INT;
75+
d VARCHAR2(20) := 'P00001';
76+
BEGIN
77+
SELECT price INTO b FROM product_master WHERE product_no = d;
78+
IF b < a THEN
79+
UPDATE product_master SET price = a WHERE product_no = d;
80+
INSERT INTO old_price_table VALUES (d, b, SYSDATE);
81+
END IF;
82+
END;
83+
84+
85+
-- <div style="page-break-after: always;"></div>
File renamed without changes.

dbms/3.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ constraint fk_product_no foreign key(product_no) references product_master(produ
4949

5050

5151
insert into sales_master values
52-
('s500001','Kiran','A/14 worli','Bombay','Mah','400002',3000,100,50,'Good'),
53-
('s500002','Raj','A/14 worli','Bombay','Mah','400002',3000,100,50,'Good'),
54-
('s500003','Ravi','P-7 Bandra','Bombay','Mah','400032',3000,200,100,'Good'),
55-
('s500004','Ashish','A/5 Juhu','Bombay','Mah','400044',3500,200,150,'Good');
52+
('s00001','Kiran','A/14 worli','Bombay','Mah','400002',3000,100,50,'Good'),
53+
('s00002','Raj','A/14 worli','Bombay','Mah','400002',3000,100,50,'Good'),
54+
('s00003','Ravi','P-7 Bandra','Bombay','Mah','400032',3000,200,100,'Good'),
55+
('s00004','Ashish','A/5 Juhu','Bombay','Mah','400044',3500,200,150,'Good');
5656

5757
insert into sales_order values
5858
('019001','1996-01-12','0001','F','N','s0001','1996-01-20','Ip'),

dbms/5.md

Whitespace-only changes.

dbms/6.sql

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
3+
4+
-- 1. Find out the product which has been sold to 'Ivan Sayross'.
5+
6+
select product_no, description from product_master where product_no in (select product_no from sales_order_details where s_order_no in (select s_order_no from sales_order where client_no in (select client_no from client_master where name = 'Ivan Sayross')));
7+
8+
9+
-- 2. Find out the product and their quantities that will have do delivered.
10+
11+
12+
select product_no, qty_disp from sales_order_details where s_order_no in (select s_order_no from sales_order where dely_type = 'F');
13+
14+
-- 3. Find the product_no and description of moving products.
15+
16+
select product_no, description from product_master where product_no in (select product_no from sales_order_details where s_order_no in (select s_order_no from sales_order where order_status = 'Ip'));
17+
18+
-- 4. Find out the names of clients who have purchased 'CD DRIVE'
19+
20+
select name from client_master where client_no in (select client_no from sales_order where s_order_no in (select s_order_no from sales_order_details where product_no = 'P00001'));
21+
22+
-- 5. List the product_no and s_order_no of customers haaving qty ordered less than 5 from the order details table for the product "1.44 floppies".
23+
24+
select product_no, s_order_no from sales_order_details where product_no = 'P00001' and qty_order < 5;
25+
26+
-- 6. Find the products and their quantities for the orders placed by 'Vandan Saitwal ' and "Ivan Bayross".
27+
28+
select product_no, qty_order from sales_order_details where s_order_no in (select s_order_no from sales_order where client_no in (select client_no from client_master where name in ('Vandan Saitwal', 'Ivan Bayross')));
29+
30+
-- 7. Find the products and their quantities for the orders placed by client_no " C00001" and "C00002"
31+
32+
select product_no, qty_order from sales_order_details where s_order_no in (select s_order_no from sales_order where client_no in ('C00001', 'C00002'));
33+
34+
35+
-- 8. Find the order No,, Client No and salesman No. where a client has been received by more than one salesman.
36+
37+
select s_order_no, client_no, salesman_no from sales_order where client_no in (select client_no from sales_order group by client_no having count(salesman_no) > 1);
38+
39+
-- 9. Display the s_order_date in the format "dd-mon-yy" e.g. "12- feb-96"
40+
41+
select date_format(s_order_date, '%d-%b-%y') from sales_order;
42+
43+
-- 10. Find the date , 15 days after date.
44+
45+
select date_format(date_add(s_order_date, interval 15 day), '%d-%b-%y') from sales_order;

dbms/7.sql

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
3+
-- Q1.- Print the description and total quantity sold for each product.
4+
5+
select description, sum(qty_order) from product_master p, sales_order_details s where p.product_no = s.product_no group by description;
6+
7+
-- Q2.- Find the value of each product sold.
8+
9+
select description, sum(qty_order * sell_price) from product_master p, sales_order_details s where p.product_no = s.product_no group by description;
10+
11+
12+
-- Q3.- Calculate the average quantity sold for each client that has a maximum order value of 15000
13+
14+
select client_no, avg(qty_order) from sales_order_details s, sales_order so where s.s_order_no = so.s_order_no and s.qty_order * s.product_rate <= 15000 group by client_no;
15+
16+
-- Q4.- Find out the products which has been sold to Ivan. -->
17+
18+
select description from product_master p , client_master c , sales_order so , sales_order_details sod where p.product_no = sod.product_no and c.client_no = so.client_no and so.s_order_no = sod.s_order_no and c.name = 'Ivan Sayross';
19+
20+
-- Q5.- Find the names of clients who have ‘CD Drive’.
21+
22+
select name from client_master c, sales_order so, sales_order_details sod where c.client_no = so.client_no and so.s_order_no = sod.s_order_no and sod.product_no = 'P00001';
23+
24+
-- Q6.- Find the products and their quantities for the orders placed by ‘Vandana’ and ‘Ivan’.
25+
26+
select product_no, qty_order from sales_order_details sod, sales_order so, client_master c where sod.s_order_no = so.s_order_no and so.client_no = c.client_no and c.name in ('Vandan Saitwal', 'Ivan Bayross');
27+
28+
-- Q7.- Select product_no, total qty_ordered for each product.
29+
30+
select product_no, sum(qty_order) from sales_order_details group by product_no;
31+
32+
-- Q8.- Select product_no, product description and qty ordered for each product.
33+
34+
35+
-- select p.product_no , p.description , sum(sod.qty_order) from product_master p , sales_order_details sod where p.product_no = sod.product_no group by p.product_no;
36+
37+
38+
39+
-- Q9.- Display the order number and day on which clients placed their order.
40+
41+
42+
select s_order_no, dayname(s_order_date) from sales_order;
43+
44+
45+
46+
-- Q10.- Display the month and Date when the order must be delivered.
47+
48+
select monthname(dely_date), day(dely_date) from sales_order;

dbms/8.sql

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
-- 1. Find the product_no and description of non- moving products.
3+
4+
select product_no, description from product_master where product_no not in (select product_no from sales_order_details where s_order_no in (select s_order_no from sales_order where order_status = 'Ip'));
5+
6+
-- 2. Find the customer name, city and pincode for the client who has placed order no “019001”
7+
8+
select name, city, pincode from client_master where client_no in (select client_no from sales_order where s_order_no = '019001');
9+
10+
-- 3. Find the client names who have placed order before the month of may 96.
11+
12+
13+
select name from client_master where client_no in (select client_no from sales_order where s_order_date < '1996-05-01');
14+
15+
16+
-- 4. Find out if product “1.44 Drive” is ordered by only client and print the client_no name to whom it was sold.
17+
18+
19+
select client_no, name from client_master where client_no in (select client_no from sales_order where s_order_no in (select s_order_no from sales_order_details where product_no = 'P00001'));
20+
21+
22+
-- 5. find the names of client who have placed orders worth Rs.10000 or more.
23+
24+
25+
select name from client_master where client_no in (select client_no from sales_order where s_order_no in (select s_order_no from sales_order_details where qty_order * product_rate >= 10000));
26+
27+
-- 6. Select the orders placed by ‘Rahul Desai”
28+
29+
30+
select s_order_no from sales_order where client_no in (select client_no from client_master where name = 'Rahul Desai');
31+
32+
33+
-- 7. Select the names of persons who are in Mr. Pradeep’s department and who have also worked on an inventory control system.
34+
35+
36+
-- select name from emp where name= 'Pradeep' and pname = 'Inventory Control System';
37+
38+
-- 8. Select all the clients and the salesman in the city of Bombay.
39+
40+
41+
select name from client_master where city = 'Bombay' UNION select sal_name from sales_master where city = 'Bombay';
42+
43+
44+
-- 9. Select salesman name in “Bombay” who has atleast one client located at “Bombay”
45+
46+
47+
select DISTINCT sal_name from sales_master where salesman_no in (select salesman_no from sales_order where client_no in (select client_no from client_master where city = 'Bombay'));
48+
49+
50+
-- 10. Select the product_no, description, qty_on-hand,cost_price of non_moving items in the product_master table.
51+
52+
53+
select product_no, description, qty_on_hand, cost_price from product_master where product_no not in (select product_no from sales_order_details where s_order_no in (select s_order_no from sales_order where order_status = 'Ip'));

0 commit comments

Comments
 (0)