Oracle Quiz #1
Problem #1: Show the results of the query below and explain your answer.
Data in the table bldgofc:
BLDG OFFICE
-------------------- ------
K Building #112
K Bldg 115
H #114
SQL> SELECT SUBSTR(bldg,1,1)||SUBSTR(office,-3,3)
2 FROM bldgofc;
Problem #2: Show the results of the query below and explain your answer.
Data in the table ofbl:
BLDGOFC
--------------------
Building K #112
#115 K
Office K#114
SQL> SELECT SUBSTR(bldgofc,instr(bldgofc,'#')+1,3)
2 FROM ofbl;
Problem #3: Show the results of the query below and explain your answer.
Data in the table donor:
IDNO NAME STADR CITY ST ZIP DATEFST YRGOAL CONTACT
----- --------------- --------------- ---------- -- ----- --------- --------- -----------
11111 Stephen Daniels 123 Elm St Seekonk MA 02345 03-JUL-98 500 John Smith
12121 Jennifer Ames 24 Benefit St Providence RI 02045 24-MAY-97 400 Susan Jones
22222 Carl Hersey 24 Benefit St Providence RI 02045 03-JAN-98 Susan Jones
23456 Susan Ash 21 Main St Fall River MA 02720 04-MAR-92 100 Amy Costa
33333 Nancy Taylor 26 Oak St Fall River MA 02720 04-MAR-92 50 John Adams
34567 Robert Brooks 36 Pine St Fall River MA 02720 04-APR-98 50 Amy Costa
SQL> SELECT RTRIM(TO_CHAR(datefst,'DY'))|| ' is day ' ||
2 RTRIM(TO_CHAR(datefst,'DDD'))
3 || ' of the year ' || RTRIM(TO_CHAR(datefst,'YYYY'))
4 FROM donor;
Problem #4: Show the results of the query below and explain your answer.
SQL> SELECT SUBSTR(contact,ROUND(MOD(yrgoal,7),0),5)
2 FROM donor;