You are on page 1of 7

Course Code CS351

Database Management System


Description
1
College / Department:
LabExer No. 004
Online Education
Laboratory Exercise

Direction:
 Use the Parts table in LabExer003 (previous week)
 This activity covers all SELECT statement discussed starting week 5-7.
 Based on the given table: PARTS as shown below, write the PL/SQL in order to get the printed output
per number. Write your answer in a short bond paper.
 Do not used IN condition.
 Copy and paste the PL/SQL code on the space provided after each questions.
Table Name: PARTS
PARTNUM DESCRIPTION ONHAND CLAS WAREHOUSE PRICE
S
AT94 IRON 50 HW 3 2495
BVO6 HOME GYM 45 SG 2 79495
CD52 MICROWAVE OVEN 32 AP 1 165
DL71 CORDLESS DRILL 21 HW 3 12995
DR93 GAS RANGE 21 AP 2 495
DW11 WASHER 12 AP 3 399
FD21 STAND MIXER 22 HW 3 159
KL62 DRYER 12 AP 1 349
KT03 DISHWASHER 8 AP 3 595
KV29 TREADMILL 9 SG 2 1390

PARTS structure
COLUMN DATA KEY NULL
NAME TYPE/SIZE
PARTNUM CHAR – 4 PRIMARY NOT NULL
DESCRIPTION VARCHAR – 20 NOT NULL
ONHAND NUMBER – 6
CLASS CHAR – 5
WAREHOUSE NUMBER – 6
PRICE NUMBER – 6

*****Before I will start here I need to change the CLASS CHAR(5) to CHAR(2) but it cannot be modified and
also the GAS RANGE ON HAND in the lab is 21 but in the lab is 8…. AKO lng po ba mali po….

1.

select PART, DESCRIPTION, ONHAND, CLASS, WAREHOUSE, PRICE


from PARTS
order by PRICE asc;

2.

select DESCRIPTION, ONHAND, CLASS


from PARTS
where CLASS=’HW’;

3.
select DESCRIPTION, ONHAND, CLASS
from PARTS
where DESCRIPTION like ‘%R’;

4.

select DESCRIPTION, ONHAND, CLASS


from PARTS
where DESCRIPTION like ‘%LL’;

5.

select DESCRIPTION, ONHAND, CLASS


from PARTS
where DESCRIPTION like ‘%AS%’ and PARTNUM like ‘D%’;

6.

select DESCRIPTION, ONHAND, CLASS


from PARTS
where DESCRIPTION like ‘D%’;
7.

select distinct WAREHOUSE


from PARTS;

8.

select distinct WAREHOUSE, CLASS


from PARTS;

9.

select PARTNUM||’ belongs to ‘||DESCRIPTION as


“RECORD”
from PARTS
where PARTNUM like ‘%V%’;
10.

select DESCRIPTION, PRICE*.5+PRICE-100


from PARTS
where DESCRIPTION like ‘_O%’;

11.

update PARTS
set ONHAND=8
where PARTNUM=’DR93’;

select DESCRIPTION, ONHAND, ONHAND+10 as


“NEW ONHAND”
from PARTS
where ONHAND<=12;

12.
select DESCRIPTION, ONHAND, CLASS
from PARTS
where ONHAND=12;

13.

select DESCRIPTION, ONHAND, CLASS


from PARTS
where PARTNUM=’CD52’ or ONHAND=8;

14.

select DESCRIPTION, ONHAND, CLASS


from PARTS
15. What is the advantage of using Logical Condition?
 The advantages of using Logical Condition are testing for the truth of some
condition, comparing the statement and returning for a Boolean data type.

You might also like