Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
8 views3 pages

Prog 8

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Prog 8

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Queries on Operators

1. Find the pname, phoneno and cost of parts which have cost equal to
or greater than 200 and less than or equal to 600.

INSERT INTO part VALUES(311, 'Net', 'Grey', 300);


1 row created.

INSERT INTO part VALUES (312, 'Nut', 'Black', 400);


1 row created.

INSERT INTO supplies VALUES(204001, 311, 10, date '2000-05-01');


1 row created.

SELECT P.Pname, S.phone, P.price FROM Part P JOIN Supplies SP ON


P.PID = SP.PID JOIN Supplier S ON SP.SID = S.SID WHERE P.price >=
200
AND P.price <= 600;

PNAME PHONE PRICE

Net 9876543210 300

2. Find the sname, SID and branch of suppliers who are in ‘local’
branch or ‘global’ branch

INSERT INTO supplier VALUES(204011, 'Pooja', 'Local', 'Patna', 5647891234);


1 row created.
INSERT INTO supplier VALUES(204012, 'Reshma', 'Global', 'Port
Blair', 5647891234);
1 row created.

INSERT INTO Supplies VALUES(204011, 311, 40, Date '2021-01-12');


1 row created.

SELECT Sname, SID, branch FROM Supplier WHERE branch IN


('Local', 'Global');
SNAME SID BRANCH

Pooja 204011 Local


Reshma 204012 Global

3. Find the pname, phoneno and cost of parts for which cost is
between 200 and 600

SELECT P.Pname, S.phone, P.price FROM Part P JOIN Supplies SP


ON P.PID = SP.PID JOIN Supplier S ON SP.SID = S.SID WHERE
P.price BETWEEN 200 AND 600;
NAME PHONE PRICE

Net 9876543210 300


Net 5647891234 300

4. Find the pname and color of parts, which has the word ‘NET’
anywhere in its pname.

SELECT Pname, color FROM Part WHERE Pname LIKE


'%Net%';
PNAME COLOR

Net Grey

5. Find the PID and pname of parts with pname either ‘NUT’ or ‘BOLT’

SELECT PID, Pname FROM Part WHERE Pname IN ('Nut',


'Bolt');
PID PNAME

301 Bolt
302 Nut
312 Nut

6. List the suppliers who supplied parts on ‘1st may2000’, ‘12 JAN
2021’ ,’17 dec 2000’ , ’10 Jan 2021’

SELECT DISTINCT S.* FROM Supplier S JOIN Supplies SP ON S.SID = SP.SID


WHERE SP.date_supplied IN (DATE '2000-05-01', DATE '2021-01-12', DATE
'2000-12-17', DATE '2021-01-10');
SID SNAME BRANCH CITY PHONE

204001 Ravi Kumar North Delhi 9876543210


204011 Pooja Local Patna 5647891234

7. Find all the distinct costs of parts

SELECT DISTINCT price FROM


Part;
PRICE

2.5
1.2
1
.8
1.5
5
6
7.2
3.3
4.4
300
400

12 rows selected.

You might also like