SlideShare a Scribd company logo
1 of 34
Download to read offline
NEIL MMATHEWW - A233247100
DB
002 - 3C
BMS
CS4 – Y3
S LA
305
AB
INDEX
No Date Topic Sign
1 01-AUG-11 Q0: Creating Tables.
2 01-AUG-11 Q1: Solving Queries based on EMP table.
3 08-AUG-11 Q2: Solving Queries using GROUP BY
4 29-AUG-11 Q3: Solving Queries based on ITEM MASTER table.
5 05-SEP-11 Q3: Nested Queries using TRANSACTION table.
6 26-SEP-11 Q4: Queries on Self Joins, Outer Joins, TOP N QUERY
and nested queries on EMP table.
7 17–OCT-11 Q5: Queries using 10 SQL functions.
QO
(i) Creating table EMP.
CREATE TABLE EMP (
EMPNO NUMBER(4),
ENAME VARCHAR2(20),
JOB CHAR(10),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(9,2),
COMM NUMBER(7,2),
DEPTNO NUMBER(2)
);
Table created.
(ii) After Inserting values, Show all rows of table EMP.
SELECT * FROM EMP;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 Smith Clerk 7902 17-DEC-80 800 20
7499 Allen Salesman 7698 20-FEB-81 1600 300 30
7521 Ward Salesman 7698 22-FEB-81 1250 500 30
7566 Jones Manager 7839 02-APR-81 2975 20
7654 Martin Salesman 7698 28-SEP-81 1250 1400 30
7698 Blake Manager 7839 01-MAY-81 2850 30
7782 Clark Manager 7839 09-JUN-81 2450 10
7788 Scott Analyst 7566 09-DEC-82 3000 20
7839 King President 17-NOV-81 5000 10
7844 Turner Salesman 7698 08-SEP-81 1500 0 30
7876 Adams Clerk 7788 03-DEC-81 950 30
7902 Ford Analyst 7566 04-DEC-81 3000 20
12 rows selected.
(i) Creating table DEPT.
CREATE TABLE DEPT_NM (
DEPTNO NUMBER(2),
DNAME varchar2(20),
LOC varchar2(10)
);
Table created.
(ii) After Inserting values, Show all rows of table DEPT.
SELECT * FROM DEPT_NM;
DEPTNO DNAME LOC
10 Accounting New York
20 Research Dallas
30 Sales Chicago
40 Operations Boston
(i) Creating table ITEM_MASTER.
CREATE TABLE ITEM_MASTER (
ITNO NUMBER(4) PRIMARY KEY,
NAME VARCHAR2(20) NOT NULL,
QOH NUMBER(5) DEFAULT 100,
CLASS VARCHAR2(1) NOT NULL CHECK (CLASS IN ('A','B','C')),
UOM VARCHAR2(4),
ROL NUMBER(5),
ROQ NUMBER(5),
RATE NUMBER(8,2) NOT NULL
);
Table created.
(ii) After Inserting values, Show all rows of table ITEM_MASTER.
SELECT * FROM ITEM_MASTER;
ITNO NAME QOH CLA UOM ROL ROQ RATE
1090 Hammer 234 A pcs 12 34 400.9
1089 Saw 456 B pcs 17 23 800.89
1088 Lawn Mover 123 C pcs 21 21 5000.88
1087 Dish Washer 234 A pcs 76 45 950.87
1067 Baking Oven 145 A pcs 87 34 6000.67
1063 Spark Plug 150 C watt 34 67 750.63
1609 Alternator 168 B watt 50 56 750.09
1890 Battery 189 A volt 30 40 300.9
1378 Piston 234 B pcs 45 50 250.78
9 rows selected.
(i) Creating table TRANSACTION.
CREATE TABLE TRANSACTION_NM (
ITNO NUMBER(4),
TYPE VARCHAR2(10),
QTY NUMBER(4),
RECEIPTNO VARCHAR2(20),
DOT DATE
);
Table created.
(ii) After Inserting values, Show all rows of table TRANSACTION.
SELECT * FROM TRANSACTION_NM;
ITNO TYPE QTY RECEIPTNO DOT
1090 receive 500 A4333 01-JAN-09
1090 issue 100 A4336 23-FEB-10
1609 receive 215 A2143 23-FEB-10
1090 issue 150 A4343 12-MAR-10
1087 issue 300 B4143 01-SEP-10
1087 receive 50 A4143 16-DEC-10
1087 receive 50 A4144 20-DEC-10
1087 receive 50 A4145 30-DEC-10
1087 receive 50 A4149 11-JUN-11
1890 issue 25 C4143 15-JUL-11
1087 receive 50 A4151 20-JUL-11
1090 issue 200 A4133 01-AUG-11
1890 receive 15 C4113 10-SEP-11
1089 issue 125 C4041 19-SEP-11
1090 issue 120 A6336 25-SEP-11
1087 receive 50 A4155 26-SEP-11
16 rows selected.
Q1
(i) List the employees belonging to the department number 20.
SELECT * FROM EMP WHERE DEPTNO=20;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 Smith Clerk 7902 17-DEC-80 800 20
7566 Jones Manager 7839 02-APR-81 2975 20
7788 Scott Analyst 7566 09-DEC-82 3000 20
7902 Ford Analyst 7566 04-DEC-81 3000 20
4 rows in set.
(ii) List the Names and Salaries of the employees whose salary is more than 1000.
SELECT ENAME, SAL FROM EMP WHERE SAL>1000;
ENAME SAL
Allen 1600
Ward 1250
Jones 2975
Martin 1250
Blake 2850
Clark 2450
Scott 3000
King 5000
Turner 1500
Ford 3000
10 rows in set.
(iii) List the Employee number and Name of the Managers.
SELECT EMPNO, ENAME FROM EMP WHERE JOB LIKE 'Manager';
EMPNO ENAME
7566 Jones
7698 Blake
7782 Clark
3 rows in set.
(iv) List the name of the clerk working in department number 20.
SELECT ENAME FROM EMP WHERE JOB LIKE 'Clerk' AND DEPTNO=20;
ENAME
Smith
1 row in set.
(v) List details of employees who have joined before the end of September ’81.
SELECT * FROM EMP WHERE HIREDATE < '30-SEP-81';
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 Smith Clerk 7902 17-DEC-80 800 20
7499 Allen Salesman 7698 20-FEB-81 1600 300 30
7521 Ward Salesman 7698 22-FEB-81 1250 500 30
7566 Jones Manager 7839 02-APR-81 2975 20
7654 Martin Salesman 7698 28-SEP-81 1250 1400 30
7698 Blake Manager 7839 01-MAY-81 2850 30
7782 Clark Manager 7839 09-JUN-81 2450 10
7844 Turner Salesman 7698 08-SEP-81 1500 0 30
8 rows in set.
(vi) List the employee names of those who are not eligible for commission.
SELECT ENAME FROM EMP WHERE COMM IS NULL;
ENAME
Smith
Jones
Blake
Clark
Scott
King
Adams
Ford
8 rows in set.
(vii) List name of employees who are more than 2 years old in organization.
SELECT ENAME FROM EMP
WHERE TO_CHAR(SYSDATE,'YYYY') - TO_CHAR(HIREDATE,'YYYY') >2;
ENAME
Smith
Allen
Ward
Jones
Martin
Blake
Clark
Scott
King
Turner
Adams
Ford
12 rows selected.
(viii) List the total, maximum, minimum and average salary of employees, jobwise for
department number 20.
SELECT JOB, SUM(SAL), MAX(SAL), MIN(SAL), AVG(SAL)
FROM EMP WHERE DEPTNO=20 GROUP BY JOB;
JOB SUM(SAL) MAX(SAL) MIN(SAL) AVG(SAL)
Analyst 6000 3000 3000 3000
Clerk 800 800 800 800
Manager 2975 2975 2975 2975
3 rows in set.
(ix) List names of all employees who have ‘ll’ and ‘tt’ in their name.
SELECT ENAME FROM EMP WHERE ENAME
LIKE '%tt%' OR ENAME LIKE '%ll%';
ENAME
Allen
Scott
2 rows in set.
(x) List lowest paid employee working for each manager. Sort the output by salary.
SELECT * FROM EMP WHERE SAL IN
(SELECT MIN(SAL) FROM EMP WHERE MGR IS NOT NULL GROUP BY MGR)
ORDER BY SAL;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 Smith Clerk 7902 17-DEC-80 800 20
7876 Adams Clerk 7788 03-DEC-81 950 30
7521 Ward Salesman 7698 22-FEB-81 1250 500 30
7654 Martin Salesman 7698 28-SEP-81 1250 1400 30
7782 Clark Manager 7839 09-JUN-81 2450 10
7788 Scott Analyst 7566 09-DEC-82 3000 20
7902 Ford Analyst 7566 04-DEC-81 3000 20
7 rows selected.
Q2
(i) List the Job, No of employees in each job. The result should be in descending
order of the number of employees.
SELECT JOB, COUNT(*) FROM EMP
GROUP BY JOB ORDER BY COUNT(*) DESC;
JOB COUNT(*)
Salesman 4
Manager 3
Analyst 2
Clerk 2
President 1
5 rows selected.
(ii) List the average salary from each job excluding manager.
SELECT JOB, AVG(SAL) FROM EMP
WHERE JOB NOT LIKE 'Manager' GROUP BY JOB;
JOB AVG(SAL)
Analyst 3000
Clerk 875
President 5000
Salesman 1400
4 rows selected.
Q3
(i) Display item name, number and Qoh of all items where Qoh is more than 100.
SELECT NAME, ITNO, QOH FROM ITEM_MASTER WHERE QOH>100;
NAME ITNO QOH
Hammer 1090 234
Saw 1089 456
Lawn Mover 1088 123
Dish Washer 1087 234
Baking Oven 1067 145
Spark Plug 1063 150
Alternator 1609 168
Battery 1890 189
Piston 1378 234
9 rows selected.
(ii) List the items which have been issued more than 3 times.
SELECT ITNO, NAME FROM ITEM_MASTER WHERE ITNO IN
( SELECT ITNO FROM TRANSACTION WHERE TYPE LIKE 'issue'
GROUP BY ITNO HAVING COUNT(ITNO) > 3 );
ITNO NAME
1090 Hammer
(iii) List the item number, name and value of the cheapest item.
SELECT ITNO, NAME, RATE FROM ITEM_MASTER WHERE RATE IN
(SELECT MIN(RATE) FROM ITEM_MASTER);
1 rows selected.
ITNO NAME RATE
1378 Piston 250.78
(iv) List item
( SE
name of an
SELECT
ELECT ITNO
GROU
n item if and
T NAME FR
O FROM TR
UP BY ITNO
Dish Washer
d only if the
ROM ITEM_M
RANSACTION
O HAVING
NAME
r
item was re
MASTER WH
N WHERE TY
COUNT(ITN
eceived mor
ERE ITNO
YPE LIKE
NO) > 5 )
re than 5 tim
IN
'receive
;
mes.
'
(v) List the value of items rounded to one decimal place.
SELECT ROUND(RATE, 1) FROM ITEM_MASTER;
ROUND(RATE,1)
400.9
800.9
5000.9
950.9
6000.7
750.6
750.1
300.9
250.8
9 rows selected.
(vi) Display the first three letters of all employees.
SELECT SUBSTR(ENAME,1,3) FROM EMP;
SUBSTR(EN
Smi
All
War
Jon
Mar
Bla
Cla
Sco
Kin
Tur
Ada
For
12 rows selected.
(vii)
(viii)
SEL
ITN
1
List the d
Display li
LECT * FRO
NO N
1088 Lawn M
different uni
SELECT
p
w
v
ist of items
OM ITEM_M
NAME
Mover
it of measur
DISTINCT
pcs
watt
volt
3 row
of class C an
MASTER WHE
QOH
123 C
1 ro
rements ava
UOM FROM
UOM
ws selected
nd QOH wh
ERE CLASS
CLA UO
C pcs
ow selected.
ailable in ta
ITEM_MAS
d.
ere rate is m
LIKE ‘C’
OM ROL
2
.
ble.
STER;
more than 2
AND RATE
ROQ
1 21
2000.
E > 2000;
RATE
5000.888
(ix) List the details of all employees in department 10 and 20 in alphabetical order.
SELECT * FROM EMP WHERE DEPTNO IN (10,20) ORDER BY ENAME ASC;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7782 Clark Manager 7839 09-JUN-81 2450 10
7902 Ford Analyst 7566 04-DEC-81 3000 20
7566 Jones Manager 7839 02-APR-81 2975 20
7839 King President 17-NOV-81 5000 10
7788 Scott Analyst 7566 09-DEC-82 3000 20
7369 Smith Clerk 7902 17-DEC-80 800 20
6 rows selected.
(x) Increate the rate of class B by 12%
UPDATE ITEM_MASTER SET RATE = RATE + 0.12*RATE WHERE CLASS LIKE 'B';
3 rows updated.
SELECT * FROM ITEM_MASTER;
ITNO NAME QOH CLA UOM ROL ROQ RATE
1090 Hammer 234 A pcs 12 34 400.9
1089 Saw 456 B pcs 17 23 897
1088 Lawn Mover 123 C pcs 21 21 5000.88
1087 Dish Washer 234 A pcs 76 45 950.87
1067 Baking Oven 145 A pcs 87 34 6000.67
1063 Spark Plug 150 C watt 34 67 750.63
1609 Alternator 168 B watt 50 56 840.1
1890 Battery 189 A volt 30 40 300.9
1378 Piston 234 B pcs 45 50 280.87
9 rows selected.
(xi) List the rate of item which has at least 3 receipts.
SELECT RATE FROM ITEM_MASTER WHERE ITNO IN
( SELECT ITNO FROM TRANSACTION
GROUP BY ITNO HAVING COUNT(RECEIPTNO) > 3 );
RATE
950.87
400.9
(xii) Update the QOH of items to QOH + 100
UPDATE ITEM_MASTER SET QOH = QOH + 100;
9 rows updated.
SELECT * FROM ITEM_MASTER;
ITNO NAME QOH CLA UOM ROL ROQ RATE
1090 Hammer 334 A pcs 12 34 400.9
1089 Saw 556 B pcs 17 23 897
1088 Lawn Mover 223 C pcs 21 21 5000.88
1087 Dish Washer 334 A pcs 76 45 950.87
1067 Baking Oven 245 A pcs 87 34 6000.67
1063 Spark Plug 250 C watt 34 67 750.63
1609 Alternator 268 B watt 50 56 840.1
1890 Battery 289 A volt 30 40 300.9
1378 Piston 334 B pcs 45 50 280.87
9 rows selected.
(xiii)
ITN
1
1
1
1
Delete de
months.
NO
1090 Hamm
1089 Saw
1087 Dish W
1890 Battery
etails of item
DELETE
( SELECT
SELECT
WHERE MON
SE
NAME
mer
Washer
y
ms that have
FROM ITEM
T DISTINCT
DISTINCT
NTHS_BETW
5 ro
ELECT * F
QOH
234
456
234
189
e no transac
M_MASTER W
T ITNO FRO
MINUS
ITNO FROM
EEN(SYSDA
ows deleted.
ROM ITEM_
CLA U
A pcs
B pcs
A pcs
A volt
ctions takin
WHERE ITN
OM ITEM_M
M TRANSAC
ATE, DOT)<
.
_MASTER;
UOM ROL
s
s
s
t
g place in th
NO IN
MASTER
CTION
<=2 );
L ROQ
12 34
17 23
76 45
30 40
he last two
RATE
4 400.9
3 800.89
5 950.87
0 300.9
9
9
7
9
(xiv) List the items for which one transaction was made.
SELECT ITNO, NAME FROM ITEM_MASTER WHERE ITNO IN
( SELECT ITNO FROM TRANSACTION
GROUP BY ITNO HAVING COUNT(*) = 1 );
ITNO NAME
1089 Saw
1609 Alternator
(xv) List the number of items belonging to each class, minimum, maximum, average rates
and total value of items in each class.
SELECT CLASS, COUNT(*), MIN(RATE), MAX(RATE), AVG(RATE), SUM(RATE)
FROM ITEM_MASTER GROUP BY CLASS;
CLA COUNT(*) MIN(RATE) MAX(RATE) AVG(RATE) SUM(RATE)
A 4 300.9 6000.67 1913.335 7653.34
B 3 280.87 897 672.656667 2017.97
C 2 750.63 5000.88 2875.755 5751.51
3 rows selected.
(xvi) Create a new table having only the items of class B.
CREATE TABLE EMP_CLASS_B AS
(SELECT * FROM ITEM_MASTER WHERE CLASS LIKE 'B');
Table created.
SELECT * FROM EMP_CLASS_B;
ITNO NAME QOH CLA UOM ROL ROQ RATE
1089 Saw 556 B pcs 17 23 897
1609 Alternator 268 B watt 50 56 840.1
1378 Piston 334 B pcs 45 50 280.87
3 rows selected.
Q4
(i) List all employees’ names, jobs and deptno who have the same job as that of any
employee in department No: 20.
SELECT ENAME, JOB, DEPTNO FROM EMP_NM
WHERE JOB IN
(SELECT JOB FROM EMP_NM WHERE DEPTNO=20);
ENAME JOB DEPTNO
Adams Clerk 30
Smith Clerk 20
Clark Manager 10
Blake Manager 30
Jones Manager 20
Ford Analyst 20
Scott Analyst 20
7 rows selected.
(ii) Using Self Join, list all the employees who have joined before their manager.
SELECT E.EMPNO, E.ENAME FROM EMP_NM E, EMP_NM M
WHERE E.HIREDATE < M.HIREDATE AND E.MGR=M.EMPNO;
EMPNO ENAME
7521 Ward
7499 Allen
7782 Clark
7698 Blake
7566 Jones
7369 Smith
6 rows selected.
(iii) List all the employees who earn less than the average salary of all employees.
SELECT * FROM EMP_NM
WHERE SAL < (SELECT AVG(SAL) FROM EMP_NM);
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 Smith Clerk 7902 17-DEC-80 800 20
7499 Allen Salesman 7698 20-FEB-81 1600 300 30
7521 Ward Salesman 7698 22-FEB-81 1250 500 30
7654 Martin Salesman 7698 28-SEP-81 1250 1400 30
7844 Turner Salesman 7698 08-SEP-81 1500 0 30
7876 Adams Clerk 7788 03-DEC-89 950 30
6 rows selected.
(iv) List all the employee names along with their manager’s name. Also list the names
of those employeea who have no manager. (Outer Join)
SELECT W.ENAME AS EMPLOYEE, M.ENAME AS MANAGER
FROM EMP_NM W, EMP_NM M
WHERE W.MGR=M.EMPNO(+);
EMPLOYEE MANAGER
Ford Jones
Scott Jones
Turner Blake
Martin Blake
Ward Blake
Allen Blake
Adams Scott
Clark King
Blake King
Jones King
Smith Ford
King
12 rows selected.
(v) Display the Department which has no employees.
SELECT DEPTNO FROM DEPT_NM
WHERE DEPTNO NOT IN (SELECT DISTINCT DEPTNO FROM EMP_NM);
DEPTNO
40
1 row selected.
(vi) List details of employees who earn the minimum salary for their jobs.
SELECT * FROM EMP_NM X
WHERE SAL = (SELECT MIN(SAL) FROM EMP_NM Y WHERE X.JOB= Y.JOB)
ORDER BY JOB;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7788 Scott Analyst 7566 09-DEC-82 3000 20
7902 Ford Analyst 7566 04-DEC-81 3000 20
7369 Smith Clerk 7902 17-DEC-80 800 20
7782 Clark Manager 7839 09-JUN-81 2450 10
7839 King President 17-NOV-81 5000 10
7521 Ward Salesman 7698 22-FEB-81 1250 500 30
7654 Martin Salesman 7698 28-SEP-81 1250 1400 30
7 rows selected.
(vii) List the employee name, salary, department No for those employees who earn a
salary greater than average salary for their department. Show the output in
order of department no.
SELECT ENAME, SAL, DEPTNO FROM EMP_NM X
WHERE SAL > (SELECT AVG(SAL) FROM EMP_NM Y WHERE X.DEPTNO = Y.DEPTNO)
ORDER BY DEPTNO;
ENAME SAL DEPTNO
King 5000 10
Jones 2975 20
Ford 3000 20
Scott 3000 20
Allen 1600 30
Blake 2850 30
6 rows selected.
(viii) List details of employees who earn the highest salary for their job.
SELECT * FROM EMP_NM
WHERE JOB IN (SELECT DISTINCT JOB FROM EMP_NM)
AND SAL IN (SELECT MAX(SAL) FROM EMP_NM GROUP BY JOB);
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7876 Adams Clerk 7788 03-DEC-89 950 30
7499 Allen Salesman 7698 20-FEB-81 1600 300 30
7566 Jones Manager 7839 02-APR-81 2975 20
7902 Ford Analyst 7566 04-DEC-81 3000 20
7788 Scott Analyst 7566 09-DEC-82 3000 20
7839 King President 17-NOV-81 5000 10
6 rows selected.
(ix) List the details of those employees who are among the five highest earners of
this company. (TOP N QUERY)
SELECT *
FROM (SELECT * FROM EMP_NM ORDER BY SAL DESC)
WHERE ROWNUM<=5;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7839 King President 17-NOV-81 5000 10
7788 Scott Analyst 7566 09-DEC-82 3000 20
7902 Ford Analyst 7566 04-DEC-81 3000 20
7566 Jones Manager 7839 02-APR-81 2975 20
7698 Blake Manager 7839 01-MAY-81 2850 30
5 rows selected.
(x) List Item no, Name of items whose rate is greater than the lowest rate of an item
belonging to class B.
SELECT ITNO, NAME FROM ITEM_MASTER
WHERE RATE > ANY (SELECT RATE FROM ITEM_MASTER WHERE CLASS='B');
ITNO NAME
1067 Baking Oven
1088 Lawn Mover
1087 Dish Washer
1089 Saw
1063 Spark Plug
1609 Alternator
1090 Hammer
1890 Battery
8 rows selected.
Q5
(i) Perform a query using CEIL and FLOOR. (Arithmetic Functions)
SELECT CEIL(7.3), FLOOR(7.3) FROM DUAL;
CEIL(7.3) FLOOR(7.3)
8 7
(ii) Perform a query using ROUND and TRUNC.
SELECT ROUND(7.326, 2), TRUNC(7.326, 2) FROM DUAL;
ROUND(7.326,2) TRUNC(7.326,2)
7.33 7.32
(iii) Perform a query using MOD.
SELECT MOD(12, 5) FROM DUAL;
MOD(12,5)
2
(iv) Perform a query using RPAD (String Functions)
SELECT RPAD('Hello', 7, '!') FROM DUAL;
RPAD('HELLO',7,'!')
Hello!!
(v) Perform a query using LTRIM and RTRIM.
SELECT RTRIM ( LTRIM('MMMAGNETSS', 'M') , 'S') FROM DUAL;
RTRIM(LTRIM('MM
AGNET
(vi) Perform a query using TRANSLATE.
SELECT DNAME, TRANSLATE( DNAME, 'aieou', 'uoei') FROM DEPT_NM;
TRANSLATE(DNAME,'AIEOU','UOEI')
Accounting Accintong
Research Reseurch
Sales Sules
Operations Operutoins
(vii)
(viii)
Perform
SELE
Perform
SELECT TO
a query usin
ECT NEXT_D
26-OCT
a query usin
O_CHAR( TO
T
Tuesda
ng NEXT_DA
DAY('25-O
NEXT_
T-11
ng TO_CHAR
O_DATE('2
TO_CHAR(TO
ay
AY. (Date Fu
CT-2011',
_DAY('25-OCT
R and TO_D
5-OCT-201
O_DATE('25-
unctions)
, 'WED') F
T-2
DATE.
11') , 'Da
-OCT-201
FROM DUAL
ay') FROM
L;
M DUAL;
(ix) Perform a query using NVL. (General Functions)
SELECT EMPNO, SAL, COMM, SAL + COMM, SAL + NVL(COMM, 0) FROM EMP_NM;
EMPNO SAL COMM SAL+COMM SAL+NVL(COMM,0)
7369 800 800
7499 1600 300 1900 1900
7521 1250 500 1750 1750
7566 2975 2975
7654 1250 1400 2650 2650
7698 2850 2850
7782 2450 2450
7788 3000 3000
7839 5000 5000
7844 1500 0 1500 1500
7876 950 950
7902 3000 3000
12 rows selected.
(x) Perform a query using DECODE.
SELECT NAME, DECODE (NAME, 'Hammer', 'Mallet', 'Saw', 'Axe',
'Battery', 'Generator’, ’Unavailable') FROM ITEM_MASTER;
NAME DECODE(NAME,'HAMMER','MALLET','SA
Hammer Mallet
Saw Axe
Lawn Mover Unavailable
Dish Washer Unavailable
Baking Oven Unavailable
Spark Plug Unavailable
Alternator Unavailable
Battery Generator
Piston Unavailable
9 rows selected.

More Related Content

What's hot

document for Voice banking system mini project
document for Voice banking system mini projectdocument for Voice banking system mini project
document for Voice banking system mini projectJal Pari
 
Presentation microsoft office 2013 akshay
Presentation microsoft office 2013 akshayPresentation microsoft office 2013 akshay
Presentation microsoft office 2013 akshayAkshay Singh
 
Online old books sales by hemraj gahlot
Online old books sales by hemraj gahlotOnline old books sales by hemraj gahlot
Online old books sales by hemraj gahlotHemraj Gahlot
 
Microsoft excel tutorial (part i)
Microsoft excel tutorial (part i)Microsoft excel tutorial (part i)
Microsoft excel tutorial (part i)mariavarey
 
Application software
Application softwareApplication software
Application softwareKawsar Ahmed
 
Unit iii(part b - architectural design)
Unit   iii(part b - architectural design)Unit   iii(part b - architectural design)
Unit iii(part b - architectural design)BALAJI A
 
Quickstart Microsoft access 2013
Quickstart Microsoft access 2013Quickstart Microsoft access 2013
Quickstart Microsoft access 2013comatsg
 
17 ознайомлення з електронними таблицями
17 ознайомлення з електронними таблицями17 ознайомлення з електронними таблицями
17 ознайомлення з електронними таблицямиОльга Казанцева
 
17337071 srs-library-management-system
17337071 srs-library-management-system17337071 srs-library-management-system
17337071 srs-library-management-systemANAS NAIN
 
Book Store Management System - Functional Requirements - 2021
Book Store Management System - Functional Requirements - 2021Book Store Management System - Functional Requirements - 2021
Book Store Management System - Functional Requirements - 2021Bharat Chawda
 

What's hot (18)

document for Voice banking system mini project
document for Voice banking system mini projectdocument for Voice banking system mini project
document for Voice banking system mini project
 
Presentation microsoft office 2013 akshay
Presentation microsoft office 2013 akshayPresentation microsoft office 2013 akshay
Presentation microsoft office 2013 akshay
 
Online old books sales by hemraj gahlot
Online old books sales by hemraj gahlotOnline old books sales by hemraj gahlot
Online old books sales by hemraj gahlot
 
Microsoft excel tutorial (part i)
Microsoft excel tutorial (part i)Microsoft excel tutorial (part i)
Microsoft excel tutorial (part i)
 
MS Excel
MS ExcelMS Excel
MS Excel
 
Library Management System
Library Management SystemLibrary Management System
Library Management System
 
Application software
Application softwareApplication software
Application software
 
Unit iii(part b - architectural design)
Unit   iii(part b - architectural design)Unit   iii(part b - architectural design)
Unit iii(part b - architectural design)
 
Ch9 evolution
Ch9 evolutionCh9 evolution
Ch9 evolution
 
Quickstart Microsoft access 2013
Quickstart Microsoft access 2013Quickstart Microsoft access 2013
Quickstart Microsoft access 2013
 
11.online library management system
11.online library management system11.online library management system
11.online library management system
 
17 ознайомлення з електронними таблицями
17 ознайомлення з електронними таблицями17 ознайомлення з електронними таблицями
17 ознайомлення з електронними таблицями
 
Billing project
Billing projectBilling project
Billing project
 
17337071 srs-library-management-system
17337071 srs-library-management-system17337071 srs-library-management-system
17337071 srs-library-management-system
 
Java presentation
Java presentationJava presentation
Java presentation
 
Book Store Management System - Functional Requirements - 2021
Book Store Management System - Functional Requirements - 2021Book Store Management System - Functional Requirements - 2021
Book Store Management System - Functional Requirements - 2021
 
Online second hand book store project report
Online second hand book store project reportOnline second hand book store project report
Online second hand book store project report
 
Library management system using java technology
Library management system using java technologyLibrary management system using java technology
Library management system using java technology
 

Similar to DBMS Lab

80 different SQL Queries with output
80 different SQL Queries with output80 different SQL Queries with output
80 different SQL Queries with outputNexus
 
Sangam 19 - Analytic SQL
Sangam 19 - Analytic SQLSangam 19 - Analytic SQL
Sangam 19 - Analytic SQLConnor McDonald
 
Get your moneys worth out of your database
Get your moneys worth out of your databaseGet your moneys worth out of your database
Get your moneys worth out of your databasePatrick Barel
 
SQL WORKSHOP::Lecture 4
SQL WORKSHOP::Lecture 4SQL WORKSHOP::Lecture 4
SQL WORKSHOP::Lecture 4Umair Amjad
 
Make your data dance: PIVOT, UNPIVOT & GROUP BY extensions
Make your data dance: PIVOT, UNPIVOT & GROUP BY extensionsMake your data dance: PIVOT, UNPIVOT & GROUP BY extensions
Make your data dance: PIVOT, UNPIVOT & GROUP BY extensionsstewashton
 
DATABASE MANAGEMENT SYSTEM PRACTICAL LAB ASSIGNMENT 1
DATABASE MANAGEMENT SYSTEM PRACTICAL LAB ASSIGNMENT 1DATABASE MANAGEMENT SYSTEM PRACTICAL LAB ASSIGNMENT 1
DATABASE MANAGEMENT SYSTEM PRACTICAL LAB ASSIGNMENT 1Raj vardhan
 
Row patternmatching12ctech14
Row patternmatching12ctech14Row patternmatching12ctech14
Row patternmatching12ctech14stewashton
 
Oracle (SQL), Sulieman Khudruj
Oracle (SQL), Sulieman KhudrujOracle (SQL), Sulieman Khudruj
Oracle (SQL), Sulieman KhudrujSulieman Khudruj
 
Analysis and design of 15 storey office and
Analysis and design of 15 storey office andAnalysis and design of 15 storey office and
Analysis and design of 15 storey office andMasroor Alam
 
Analysis and design of 15 storey office and
Analysis and design of 15 storey office andAnalysis and design of 15 storey office and
Analysis and design of 15 storey office andMasroor Alam
 
COIS 420 - Practice04
COIS 420 - Practice04COIS 420 - Practice04
COIS 420 - Practice04Angel G Diaz
 
Database Management System
Database Management SystemDatabase Management System
Database Management SystemHitesh Mohapatra
 

Similar to DBMS Lab (20)

My Sql
My Sql My Sql
My Sql
 
80 different SQL Queries with output
80 different SQL Queries with output80 different SQL Queries with output
80 different SQL Queries with output
 
Sangam 19 - Analytic SQL
Sangam 19 - Analytic SQLSangam 19 - Analytic SQL
Sangam 19 - Analytic SQL
 
Les04 Displaying Data From Multiple Table
Les04 Displaying Data From Multiple TableLes04 Displaying Data From Multiple Table
Les04 Displaying Data From Multiple Table
 
ORACLE NOTES
ORACLE NOTESORACLE NOTES
ORACLE NOTES
 
Sql lab experiments
Sql lab experimentsSql lab experiments
Sql lab experiments
 
Get your moneys worth out of your database
Get your moneys worth out of your databaseGet your moneys worth out of your database
Get your moneys worth out of your database
 
SQL WORKSHOP::Lecture 4
SQL WORKSHOP::Lecture 4SQL WORKSHOP::Lecture 4
SQL WORKSHOP::Lecture 4
 
Make your data dance: PIVOT, UNPIVOT & GROUP BY extensions
Make your data dance: PIVOT, UNPIVOT & GROUP BY extensionsMake your data dance: PIVOT, UNPIVOT & GROUP BY extensions
Make your data dance: PIVOT, UNPIVOT & GROUP BY extensions
 
DATABASE MANAGEMENT SYSTEM PRACTICAL LAB ASSIGNMENT 1
DATABASE MANAGEMENT SYSTEM PRACTICAL LAB ASSIGNMENT 1DATABASE MANAGEMENT SYSTEM PRACTICAL LAB ASSIGNMENT 1
DATABASE MANAGEMENT SYSTEM PRACTICAL LAB ASSIGNMENT 1
 
Dbms 2
Dbms 2Dbms 2
Dbms 2
 
Row patternmatching12ctech14
Row patternmatching12ctech14Row patternmatching12ctech14
Row patternmatching12ctech14
 
Analytic SQL Sep 2013
Analytic SQL Sep 2013Analytic SQL Sep 2013
Analytic SQL Sep 2013
 
SQL BASIC QUERIES
SQL  BASIC QUERIES SQL  BASIC QUERIES
SQL BASIC QUERIES
 
Oracle (SQL), Sulieman Khudruj
Oracle (SQL), Sulieman KhudrujOracle (SQL), Sulieman Khudruj
Oracle (SQL), Sulieman Khudruj
 
SQL.pptx
SQL.pptxSQL.pptx
SQL.pptx
 
Analysis and design of 15 storey office and
Analysis and design of 15 storey office andAnalysis and design of 15 storey office and
Analysis and design of 15 storey office and
 
Analysis and design of 15 storey office and
Analysis and design of 15 storey office andAnalysis and design of 15 storey office and
Analysis and design of 15 storey office and
 
COIS 420 - Practice04
COIS 420 - Practice04COIS 420 - Practice04
COIS 420 - Practice04
 
Database Management System
Database Management SystemDatabase Management System
Database Management System
 

More from Neil Mathew

AMIZONER: Weekly Progress Reports
AMIZONER: Weekly Progress ReportsAMIZONER: Weekly Progress Reports
AMIZONER: Weekly Progress ReportsNeil Mathew
 
AMIZONER: Final Report
AMIZONER: Final ReportAMIZONER: Final Report
AMIZONER: Final ReportNeil Mathew
 
Computer Graphics Lab
Computer Graphics LabComputer Graphics Lab
Computer Graphics LabNeil Mathew
 
Programming in C Lab
Programming in C LabProgramming in C Lab
Programming in C LabNeil Mathew
 
Role of IT & Computer in Environment
Role of IT & Computer in EnvironmentRole of IT & Computer in Environment
Role of IT & Computer in EnvironmentNeil Mathew
 
Data Structures Lab
Data Structures LabData Structures Lab
Data Structures LabNeil Mathew
 
Communication Assessment File
Communication Assessment FileCommunication Assessment File
Communication Assessment FileNeil Mathew
 
Cloud Computing and Google's advancement in the field
Cloud Computing and Google's advancement in the fieldCloud Computing and Google's advancement in the field
Cloud Computing and Google's advancement in the fieldNeil Mathew
 
Unix Programming Lab
Unix Programming LabUnix Programming Lab
Unix Programming LabNeil Mathew
 
The Cube - Class XII Project
The Cube - Class XII ProjectThe Cube - Class XII Project
The Cube - Class XII ProjectNeil Mathew
 
Copywriting & Storyboarding (Advertising & Sales Promotion)
Copywriting & Storyboarding (Advertising & Sales Promotion)Copywriting & Storyboarding (Advertising & Sales Promotion)
Copywriting & Storyboarding (Advertising & Sales Promotion)Neil Mathew
 
American Airlines Merger (Management In Action Case Study)
American Airlines Merger (Management In Action Case Study)American Airlines Merger (Management In Action Case Study)
American Airlines Merger (Management In Action Case Study)Neil Mathew
 
Good Governance Leads To Flourish Society & Nation (BS SAP)
Good Governance Leads To Flourish Society & Nation (BS SAP)Good Governance Leads To Flourish Society & Nation (BS SAP)
Good Governance Leads To Flourish Society & Nation (BS SAP)Neil Mathew
 
High Fortune (Product Brand Management)
High Fortune (Product Brand Management)High Fortune (Product Brand Management)
High Fortune (Product Brand Management)Neil Mathew
 
Cost Benefit Analysis in Public Project Appraisal (PPAC)
Cost Benefit Analysis in Public Project Appraisal (PPAC)Cost Benefit Analysis in Public Project Appraisal (PPAC)
Cost Benefit Analysis in Public Project Appraisal (PPAC)Neil Mathew
 
Corportate Entrepreneurship at WIPRO
Corportate Entrepreneurship at WIPROCorportate Entrepreneurship at WIPRO
Corportate Entrepreneurship at WIPRONeil Mathew
 
Consumer Perception of Job Seekers in updating their Job Profiles on Job Portals
Consumer Perception of Job Seekers in updating their Job Profiles on Job PortalsConsumer Perception of Job Seekers in updating their Job Profiles on Job Portals
Consumer Perception of Job Seekers in updating their Job Profiles on Job PortalsNeil Mathew
 
How OLX changed the consumer involvement in the Scrap Market
How OLX changed the consumer involvement in the Scrap MarketHow OLX changed the consumer involvement in the Scrap Market
How OLX changed the consumer involvement in the Scrap MarketNeil Mathew
 
Innovation Jockeys 3 - Gramseva: Kisan
Innovation Jockeys 3 - Gramseva: KisanInnovation Jockeys 3 - Gramseva: Kisan
Innovation Jockeys 3 - Gramseva: KisanNeil Mathew
 

More from Neil Mathew (20)

AMIZONER: Weekly Progress Reports
AMIZONER: Weekly Progress ReportsAMIZONER: Weekly Progress Reports
AMIZONER: Weekly Progress Reports
 
AMIZONER: Final Report
AMIZONER: Final ReportAMIZONER: Final Report
AMIZONER: Final Report
 
Computer Graphics Lab
Computer Graphics LabComputer Graphics Lab
Computer Graphics Lab
 
Programming in C Lab
Programming in C LabProgramming in C Lab
Programming in C Lab
 
Role of IT & Computer in Environment
Role of IT & Computer in EnvironmentRole of IT & Computer in Environment
Role of IT & Computer in Environment
 
French Open
French OpenFrench Open
French Open
 
Data Structures Lab
Data Structures LabData Structures Lab
Data Structures Lab
 
Communication Assessment File
Communication Assessment FileCommunication Assessment File
Communication Assessment File
 
Cloud Computing and Google's advancement in the field
Cloud Computing and Google's advancement in the fieldCloud Computing and Google's advancement in the field
Cloud Computing and Google's advancement in the field
 
Unix Programming Lab
Unix Programming LabUnix Programming Lab
Unix Programming Lab
 
The Cube - Class XII Project
The Cube - Class XII ProjectThe Cube - Class XII Project
The Cube - Class XII Project
 
Copywriting & Storyboarding (Advertising & Sales Promotion)
Copywriting & Storyboarding (Advertising & Sales Promotion)Copywriting & Storyboarding (Advertising & Sales Promotion)
Copywriting & Storyboarding (Advertising & Sales Promotion)
 
American Airlines Merger (Management In Action Case Study)
American Airlines Merger (Management In Action Case Study)American Airlines Merger (Management In Action Case Study)
American Airlines Merger (Management In Action Case Study)
 
Good Governance Leads To Flourish Society & Nation (BS SAP)
Good Governance Leads To Flourish Society & Nation (BS SAP)Good Governance Leads To Flourish Society & Nation (BS SAP)
Good Governance Leads To Flourish Society & Nation (BS SAP)
 
High Fortune (Product Brand Management)
High Fortune (Product Brand Management)High Fortune (Product Brand Management)
High Fortune (Product Brand Management)
 
Cost Benefit Analysis in Public Project Appraisal (PPAC)
Cost Benefit Analysis in Public Project Appraisal (PPAC)Cost Benefit Analysis in Public Project Appraisal (PPAC)
Cost Benefit Analysis in Public Project Appraisal (PPAC)
 
Corportate Entrepreneurship at WIPRO
Corportate Entrepreneurship at WIPROCorportate Entrepreneurship at WIPRO
Corportate Entrepreneurship at WIPRO
 
Consumer Perception of Job Seekers in updating their Job Profiles on Job Portals
Consumer Perception of Job Seekers in updating their Job Profiles on Job PortalsConsumer Perception of Job Seekers in updating their Job Profiles on Job Portals
Consumer Perception of Job Seekers in updating their Job Profiles on Job Portals
 
How OLX changed the consumer involvement in the Scrap Market
How OLX changed the consumer involvement in the Scrap MarketHow OLX changed the consumer involvement in the Scrap Market
How OLX changed the consumer involvement in the Scrap Market
 
Innovation Jockeys 3 - Gramseva: Kisan
Innovation Jockeys 3 - Gramseva: KisanInnovation Jockeys 3 - Gramseva: Kisan
Innovation Jockeys 3 - Gramseva: Kisan
 

Recently uploaded

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 

Recently uploaded (20)

9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 

DBMS Lab

  • 1. NEIL MMATHEWW - A233247100 DB 002 - 3C BMS CS4 – Y3 S LA 305 AB
  • 2. INDEX No Date Topic Sign 1 01-AUG-11 Q0: Creating Tables. 2 01-AUG-11 Q1: Solving Queries based on EMP table. 3 08-AUG-11 Q2: Solving Queries using GROUP BY 4 29-AUG-11 Q3: Solving Queries based on ITEM MASTER table. 5 05-SEP-11 Q3: Nested Queries using TRANSACTION table. 6 26-SEP-11 Q4: Queries on Self Joins, Outer Joins, TOP N QUERY and nested queries on EMP table. 7 17–OCT-11 Q5: Queries using 10 SQL functions.
  • 3. QO (i) Creating table EMP. CREATE TABLE EMP ( EMPNO NUMBER(4), ENAME VARCHAR2(20), JOB CHAR(10), MGR NUMBER(4), HIREDATE DATE, SAL NUMBER(9,2), COMM NUMBER(7,2), DEPTNO NUMBER(2) ); Table created. (ii) After Inserting values, Show all rows of table EMP. SELECT * FROM EMP; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 7369 Smith Clerk 7902 17-DEC-80 800 20 7499 Allen Salesman 7698 20-FEB-81 1600 300 30 7521 Ward Salesman 7698 22-FEB-81 1250 500 30 7566 Jones Manager 7839 02-APR-81 2975 20 7654 Martin Salesman 7698 28-SEP-81 1250 1400 30 7698 Blake Manager 7839 01-MAY-81 2850 30 7782 Clark Manager 7839 09-JUN-81 2450 10 7788 Scott Analyst 7566 09-DEC-82 3000 20 7839 King President 17-NOV-81 5000 10 7844 Turner Salesman 7698 08-SEP-81 1500 0 30 7876 Adams Clerk 7788 03-DEC-81 950 30 7902 Ford Analyst 7566 04-DEC-81 3000 20 12 rows selected.
  • 4. (i) Creating table DEPT. CREATE TABLE DEPT_NM ( DEPTNO NUMBER(2), DNAME varchar2(20), LOC varchar2(10) ); Table created. (ii) After Inserting values, Show all rows of table DEPT. SELECT * FROM DEPT_NM; DEPTNO DNAME LOC 10 Accounting New York 20 Research Dallas 30 Sales Chicago 40 Operations Boston
  • 5. (i) Creating table ITEM_MASTER. CREATE TABLE ITEM_MASTER ( ITNO NUMBER(4) PRIMARY KEY, NAME VARCHAR2(20) NOT NULL, QOH NUMBER(5) DEFAULT 100, CLASS VARCHAR2(1) NOT NULL CHECK (CLASS IN ('A','B','C')), UOM VARCHAR2(4), ROL NUMBER(5), ROQ NUMBER(5), RATE NUMBER(8,2) NOT NULL ); Table created. (ii) After Inserting values, Show all rows of table ITEM_MASTER. SELECT * FROM ITEM_MASTER; ITNO NAME QOH CLA UOM ROL ROQ RATE 1090 Hammer 234 A pcs 12 34 400.9 1089 Saw 456 B pcs 17 23 800.89 1088 Lawn Mover 123 C pcs 21 21 5000.88 1087 Dish Washer 234 A pcs 76 45 950.87 1067 Baking Oven 145 A pcs 87 34 6000.67 1063 Spark Plug 150 C watt 34 67 750.63 1609 Alternator 168 B watt 50 56 750.09 1890 Battery 189 A volt 30 40 300.9 1378 Piston 234 B pcs 45 50 250.78 9 rows selected.
  • 6. (i) Creating table TRANSACTION. CREATE TABLE TRANSACTION_NM ( ITNO NUMBER(4), TYPE VARCHAR2(10), QTY NUMBER(4), RECEIPTNO VARCHAR2(20), DOT DATE ); Table created. (ii) After Inserting values, Show all rows of table TRANSACTION. SELECT * FROM TRANSACTION_NM; ITNO TYPE QTY RECEIPTNO DOT 1090 receive 500 A4333 01-JAN-09 1090 issue 100 A4336 23-FEB-10 1609 receive 215 A2143 23-FEB-10 1090 issue 150 A4343 12-MAR-10 1087 issue 300 B4143 01-SEP-10 1087 receive 50 A4143 16-DEC-10 1087 receive 50 A4144 20-DEC-10 1087 receive 50 A4145 30-DEC-10 1087 receive 50 A4149 11-JUN-11 1890 issue 25 C4143 15-JUL-11 1087 receive 50 A4151 20-JUL-11 1090 issue 200 A4133 01-AUG-11 1890 receive 15 C4113 10-SEP-11 1089 issue 125 C4041 19-SEP-11 1090 issue 120 A6336 25-SEP-11 1087 receive 50 A4155 26-SEP-11 16 rows selected.
  • 7. Q1 (i) List the employees belonging to the department number 20. SELECT * FROM EMP WHERE DEPTNO=20; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 7369 Smith Clerk 7902 17-DEC-80 800 20 7566 Jones Manager 7839 02-APR-81 2975 20 7788 Scott Analyst 7566 09-DEC-82 3000 20 7902 Ford Analyst 7566 04-DEC-81 3000 20 4 rows in set. (ii) List the Names and Salaries of the employees whose salary is more than 1000. SELECT ENAME, SAL FROM EMP WHERE SAL>1000; ENAME SAL Allen 1600 Ward 1250 Jones 2975 Martin 1250 Blake 2850 Clark 2450 Scott 3000 King 5000 Turner 1500 Ford 3000 10 rows in set.
  • 8. (iii) List the Employee number and Name of the Managers. SELECT EMPNO, ENAME FROM EMP WHERE JOB LIKE 'Manager'; EMPNO ENAME 7566 Jones 7698 Blake 7782 Clark 3 rows in set. (iv) List the name of the clerk working in department number 20. SELECT ENAME FROM EMP WHERE JOB LIKE 'Clerk' AND DEPTNO=20; ENAME Smith 1 row in set.
  • 9. (v) List details of employees who have joined before the end of September ’81. SELECT * FROM EMP WHERE HIREDATE < '30-SEP-81'; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 7369 Smith Clerk 7902 17-DEC-80 800 20 7499 Allen Salesman 7698 20-FEB-81 1600 300 30 7521 Ward Salesman 7698 22-FEB-81 1250 500 30 7566 Jones Manager 7839 02-APR-81 2975 20 7654 Martin Salesman 7698 28-SEP-81 1250 1400 30 7698 Blake Manager 7839 01-MAY-81 2850 30 7782 Clark Manager 7839 09-JUN-81 2450 10 7844 Turner Salesman 7698 08-SEP-81 1500 0 30 8 rows in set. (vi) List the employee names of those who are not eligible for commission. SELECT ENAME FROM EMP WHERE COMM IS NULL; ENAME Smith Jones Blake Clark Scott King Adams Ford 8 rows in set.
  • 10. (vii) List name of employees who are more than 2 years old in organization. SELECT ENAME FROM EMP WHERE TO_CHAR(SYSDATE,'YYYY') - TO_CHAR(HIREDATE,'YYYY') >2; ENAME Smith Allen Ward Jones Martin Blake Clark Scott King Turner Adams Ford 12 rows selected.
  • 11. (viii) List the total, maximum, minimum and average salary of employees, jobwise for department number 20. SELECT JOB, SUM(SAL), MAX(SAL), MIN(SAL), AVG(SAL) FROM EMP WHERE DEPTNO=20 GROUP BY JOB; JOB SUM(SAL) MAX(SAL) MIN(SAL) AVG(SAL) Analyst 6000 3000 3000 3000 Clerk 800 800 800 800 Manager 2975 2975 2975 2975 3 rows in set. (ix) List names of all employees who have ‘ll’ and ‘tt’ in their name. SELECT ENAME FROM EMP WHERE ENAME LIKE '%tt%' OR ENAME LIKE '%ll%'; ENAME Allen Scott 2 rows in set.
  • 12. (x) List lowest paid employee working for each manager. Sort the output by salary. SELECT * FROM EMP WHERE SAL IN (SELECT MIN(SAL) FROM EMP WHERE MGR IS NOT NULL GROUP BY MGR) ORDER BY SAL; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 7369 Smith Clerk 7902 17-DEC-80 800 20 7876 Adams Clerk 7788 03-DEC-81 950 30 7521 Ward Salesman 7698 22-FEB-81 1250 500 30 7654 Martin Salesman 7698 28-SEP-81 1250 1400 30 7782 Clark Manager 7839 09-JUN-81 2450 10 7788 Scott Analyst 7566 09-DEC-82 3000 20 7902 Ford Analyst 7566 04-DEC-81 3000 20 7 rows selected.
  • 13. Q2 (i) List the Job, No of employees in each job. The result should be in descending order of the number of employees. SELECT JOB, COUNT(*) FROM EMP GROUP BY JOB ORDER BY COUNT(*) DESC; JOB COUNT(*) Salesman 4 Manager 3 Analyst 2 Clerk 2 President 1 5 rows selected. (ii) List the average salary from each job excluding manager. SELECT JOB, AVG(SAL) FROM EMP WHERE JOB NOT LIKE 'Manager' GROUP BY JOB; JOB AVG(SAL) Analyst 3000 Clerk 875 President 5000 Salesman 1400 4 rows selected.
  • 14. Q3 (i) Display item name, number and Qoh of all items where Qoh is more than 100. SELECT NAME, ITNO, QOH FROM ITEM_MASTER WHERE QOH>100; NAME ITNO QOH Hammer 1090 234 Saw 1089 456 Lawn Mover 1088 123 Dish Washer 1087 234 Baking Oven 1067 145 Spark Plug 1063 150 Alternator 1609 168 Battery 1890 189 Piston 1378 234 9 rows selected.
  • 15. (ii) List the items which have been issued more than 3 times. SELECT ITNO, NAME FROM ITEM_MASTER WHERE ITNO IN ( SELECT ITNO FROM TRANSACTION WHERE TYPE LIKE 'issue' GROUP BY ITNO HAVING COUNT(ITNO) > 3 ); ITNO NAME 1090 Hammer
  • 16. (iii) List the item number, name and value of the cheapest item. SELECT ITNO, NAME, RATE FROM ITEM_MASTER WHERE RATE IN (SELECT MIN(RATE) FROM ITEM_MASTER); 1 rows selected. ITNO NAME RATE 1378 Piston 250.78
  • 17. (iv) List item ( SE name of an SELECT ELECT ITNO GROU n item if and T NAME FR O FROM TR UP BY ITNO Dish Washer d only if the ROM ITEM_M RANSACTION O HAVING NAME r item was re MASTER WH N WHERE TY COUNT(ITN eceived mor ERE ITNO YPE LIKE NO) > 5 ) re than 5 tim IN 'receive ; mes. '
  • 18. (v) List the value of items rounded to one decimal place. SELECT ROUND(RATE, 1) FROM ITEM_MASTER; ROUND(RATE,1) 400.9 800.9 5000.9 950.9 6000.7 750.6 750.1 300.9 250.8 9 rows selected. (vi) Display the first three letters of all employees. SELECT SUBSTR(ENAME,1,3) FROM EMP; SUBSTR(EN Smi All War Jon Mar Bla Cla Sco Kin Tur Ada For 12 rows selected.
  • 19. (vii) (viii) SEL ITN 1 List the d Display li LECT * FRO NO N 1088 Lawn M different uni SELECT p w v ist of items OM ITEM_M NAME Mover it of measur DISTINCT pcs watt volt 3 row of class C an MASTER WHE QOH 123 C 1 ro rements ava UOM FROM UOM ws selected nd QOH wh ERE CLASS CLA UO C pcs ow selected. ailable in ta ITEM_MAS d. ere rate is m LIKE ‘C’ OM ROL 2 . ble. STER; more than 2 AND RATE ROQ 1 21 2000. E > 2000; RATE 5000.888
  • 20. (ix) List the details of all employees in department 10 and 20 in alphabetical order. SELECT * FROM EMP WHERE DEPTNO IN (10,20) ORDER BY ENAME ASC; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 7782 Clark Manager 7839 09-JUN-81 2450 10 7902 Ford Analyst 7566 04-DEC-81 3000 20 7566 Jones Manager 7839 02-APR-81 2975 20 7839 King President 17-NOV-81 5000 10 7788 Scott Analyst 7566 09-DEC-82 3000 20 7369 Smith Clerk 7902 17-DEC-80 800 20 6 rows selected. (x) Increate the rate of class B by 12% UPDATE ITEM_MASTER SET RATE = RATE + 0.12*RATE WHERE CLASS LIKE 'B'; 3 rows updated. SELECT * FROM ITEM_MASTER; ITNO NAME QOH CLA UOM ROL ROQ RATE 1090 Hammer 234 A pcs 12 34 400.9 1089 Saw 456 B pcs 17 23 897 1088 Lawn Mover 123 C pcs 21 21 5000.88 1087 Dish Washer 234 A pcs 76 45 950.87 1067 Baking Oven 145 A pcs 87 34 6000.67 1063 Spark Plug 150 C watt 34 67 750.63 1609 Alternator 168 B watt 50 56 840.1 1890 Battery 189 A volt 30 40 300.9 1378 Piston 234 B pcs 45 50 280.87 9 rows selected.
  • 21. (xi) List the rate of item which has at least 3 receipts. SELECT RATE FROM ITEM_MASTER WHERE ITNO IN ( SELECT ITNO FROM TRANSACTION GROUP BY ITNO HAVING COUNT(RECEIPTNO) > 3 ); RATE 950.87 400.9
  • 22. (xii) Update the QOH of items to QOH + 100 UPDATE ITEM_MASTER SET QOH = QOH + 100; 9 rows updated. SELECT * FROM ITEM_MASTER; ITNO NAME QOH CLA UOM ROL ROQ RATE 1090 Hammer 334 A pcs 12 34 400.9 1089 Saw 556 B pcs 17 23 897 1088 Lawn Mover 223 C pcs 21 21 5000.88 1087 Dish Washer 334 A pcs 76 45 950.87 1067 Baking Oven 245 A pcs 87 34 6000.67 1063 Spark Plug 250 C watt 34 67 750.63 1609 Alternator 268 B watt 50 56 840.1 1890 Battery 289 A volt 30 40 300.9 1378 Piston 334 B pcs 45 50 280.87 9 rows selected.
  • 23. (xiii) ITN 1 1 1 1 Delete de months. NO 1090 Hamm 1089 Saw 1087 Dish W 1890 Battery etails of item DELETE ( SELECT SELECT WHERE MON SE NAME mer Washer y ms that have FROM ITEM T DISTINCT DISTINCT NTHS_BETW 5 ro ELECT * F QOH 234 456 234 189 e no transac M_MASTER W T ITNO FRO MINUS ITNO FROM EEN(SYSDA ows deleted. ROM ITEM_ CLA U A pcs B pcs A pcs A volt ctions takin WHERE ITN OM ITEM_M M TRANSAC ATE, DOT)< . _MASTER; UOM ROL s s s t g place in th NO IN MASTER CTION <=2 ); L ROQ 12 34 17 23 76 45 30 40 he last two RATE 4 400.9 3 800.89 5 950.87 0 300.9 9 9 7 9
  • 24. (xiv) List the items for which one transaction was made. SELECT ITNO, NAME FROM ITEM_MASTER WHERE ITNO IN ( SELECT ITNO FROM TRANSACTION GROUP BY ITNO HAVING COUNT(*) = 1 ); ITNO NAME 1089 Saw 1609 Alternator
  • 25. (xv) List the number of items belonging to each class, minimum, maximum, average rates and total value of items in each class. SELECT CLASS, COUNT(*), MIN(RATE), MAX(RATE), AVG(RATE), SUM(RATE) FROM ITEM_MASTER GROUP BY CLASS; CLA COUNT(*) MIN(RATE) MAX(RATE) AVG(RATE) SUM(RATE) A 4 300.9 6000.67 1913.335 7653.34 B 3 280.87 897 672.656667 2017.97 C 2 750.63 5000.88 2875.755 5751.51 3 rows selected. (xvi) Create a new table having only the items of class B. CREATE TABLE EMP_CLASS_B AS (SELECT * FROM ITEM_MASTER WHERE CLASS LIKE 'B'); Table created. SELECT * FROM EMP_CLASS_B; ITNO NAME QOH CLA UOM ROL ROQ RATE 1089 Saw 556 B pcs 17 23 897 1609 Alternator 268 B watt 50 56 840.1 1378 Piston 334 B pcs 45 50 280.87 3 rows selected.
  • 26. Q4 (i) List all employees’ names, jobs and deptno who have the same job as that of any employee in department No: 20. SELECT ENAME, JOB, DEPTNO FROM EMP_NM WHERE JOB IN (SELECT JOB FROM EMP_NM WHERE DEPTNO=20); ENAME JOB DEPTNO Adams Clerk 30 Smith Clerk 20 Clark Manager 10 Blake Manager 30 Jones Manager 20 Ford Analyst 20 Scott Analyst 20 7 rows selected. (ii) Using Self Join, list all the employees who have joined before their manager. SELECT E.EMPNO, E.ENAME FROM EMP_NM E, EMP_NM M WHERE E.HIREDATE < M.HIREDATE AND E.MGR=M.EMPNO; EMPNO ENAME 7521 Ward 7499 Allen 7782 Clark 7698 Blake 7566 Jones 7369 Smith 6 rows selected.
  • 27. (iii) List all the employees who earn less than the average salary of all employees. SELECT * FROM EMP_NM WHERE SAL < (SELECT AVG(SAL) FROM EMP_NM); EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 7369 Smith Clerk 7902 17-DEC-80 800 20 7499 Allen Salesman 7698 20-FEB-81 1600 300 30 7521 Ward Salesman 7698 22-FEB-81 1250 500 30 7654 Martin Salesman 7698 28-SEP-81 1250 1400 30 7844 Turner Salesman 7698 08-SEP-81 1500 0 30 7876 Adams Clerk 7788 03-DEC-89 950 30 6 rows selected. (iv) List all the employee names along with their manager’s name. Also list the names of those employeea who have no manager. (Outer Join) SELECT W.ENAME AS EMPLOYEE, M.ENAME AS MANAGER FROM EMP_NM W, EMP_NM M WHERE W.MGR=M.EMPNO(+); EMPLOYEE MANAGER Ford Jones Scott Jones Turner Blake Martin Blake Ward Blake Allen Blake Adams Scott Clark King Blake King Jones King Smith Ford King 12 rows selected.
  • 28. (v) Display the Department which has no employees. SELECT DEPTNO FROM DEPT_NM WHERE DEPTNO NOT IN (SELECT DISTINCT DEPTNO FROM EMP_NM); DEPTNO 40 1 row selected. (vi) List details of employees who earn the minimum salary for their jobs. SELECT * FROM EMP_NM X WHERE SAL = (SELECT MIN(SAL) FROM EMP_NM Y WHERE X.JOB= Y.JOB) ORDER BY JOB; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 7788 Scott Analyst 7566 09-DEC-82 3000 20 7902 Ford Analyst 7566 04-DEC-81 3000 20 7369 Smith Clerk 7902 17-DEC-80 800 20 7782 Clark Manager 7839 09-JUN-81 2450 10 7839 King President 17-NOV-81 5000 10 7521 Ward Salesman 7698 22-FEB-81 1250 500 30 7654 Martin Salesman 7698 28-SEP-81 1250 1400 30 7 rows selected.
  • 29. (vii) List the employee name, salary, department No for those employees who earn a salary greater than average salary for their department. Show the output in order of department no. SELECT ENAME, SAL, DEPTNO FROM EMP_NM X WHERE SAL > (SELECT AVG(SAL) FROM EMP_NM Y WHERE X.DEPTNO = Y.DEPTNO) ORDER BY DEPTNO; ENAME SAL DEPTNO King 5000 10 Jones 2975 20 Ford 3000 20 Scott 3000 20 Allen 1600 30 Blake 2850 30 6 rows selected. (viii) List details of employees who earn the highest salary for their job. SELECT * FROM EMP_NM WHERE JOB IN (SELECT DISTINCT JOB FROM EMP_NM) AND SAL IN (SELECT MAX(SAL) FROM EMP_NM GROUP BY JOB); EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 7876 Adams Clerk 7788 03-DEC-89 950 30 7499 Allen Salesman 7698 20-FEB-81 1600 300 30 7566 Jones Manager 7839 02-APR-81 2975 20 7902 Ford Analyst 7566 04-DEC-81 3000 20 7788 Scott Analyst 7566 09-DEC-82 3000 20 7839 King President 17-NOV-81 5000 10 6 rows selected.
  • 30. (ix) List the details of those employees who are among the five highest earners of this company. (TOP N QUERY) SELECT * FROM (SELECT * FROM EMP_NM ORDER BY SAL DESC) WHERE ROWNUM<=5; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 7839 King President 17-NOV-81 5000 10 7788 Scott Analyst 7566 09-DEC-82 3000 20 7902 Ford Analyst 7566 04-DEC-81 3000 20 7566 Jones Manager 7839 02-APR-81 2975 20 7698 Blake Manager 7839 01-MAY-81 2850 30 5 rows selected. (x) List Item no, Name of items whose rate is greater than the lowest rate of an item belonging to class B. SELECT ITNO, NAME FROM ITEM_MASTER WHERE RATE > ANY (SELECT RATE FROM ITEM_MASTER WHERE CLASS='B'); ITNO NAME 1067 Baking Oven 1088 Lawn Mover 1087 Dish Washer 1089 Saw 1063 Spark Plug 1609 Alternator 1090 Hammer 1890 Battery 8 rows selected.
  • 31. Q5 (i) Perform a query using CEIL and FLOOR. (Arithmetic Functions) SELECT CEIL(7.3), FLOOR(7.3) FROM DUAL; CEIL(7.3) FLOOR(7.3) 8 7 (ii) Perform a query using ROUND and TRUNC. SELECT ROUND(7.326, 2), TRUNC(7.326, 2) FROM DUAL; ROUND(7.326,2) TRUNC(7.326,2) 7.33 7.32 (iii) Perform a query using MOD. SELECT MOD(12, 5) FROM DUAL; MOD(12,5) 2
  • 32. (iv) Perform a query using RPAD (String Functions) SELECT RPAD('Hello', 7, '!') FROM DUAL; RPAD('HELLO',7,'!') Hello!! (v) Perform a query using LTRIM and RTRIM. SELECT RTRIM ( LTRIM('MMMAGNETSS', 'M') , 'S') FROM DUAL; RTRIM(LTRIM('MM AGNET (vi) Perform a query using TRANSLATE. SELECT DNAME, TRANSLATE( DNAME, 'aieou', 'uoei') FROM DEPT_NM; TRANSLATE(DNAME,'AIEOU','UOEI') Accounting Accintong Research Reseurch Sales Sules Operations Operutoins
  • 33. (vii) (viii) Perform SELE Perform SELECT TO a query usin ECT NEXT_D 26-OCT a query usin O_CHAR( TO T Tuesda ng NEXT_DA DAY('25-O NEXT_ T-11 ng TO_CHAR O_DATE('2 TO_CHAR(TO ay AY. (Date Fu CT-2011', _DAY('25-OCT R and TO_D 5-OCT-201 O_DATE('25- unctions) , 'WED') F T-2 DATE. 11') , 'Da -OCT-201 FROM DUAL ay') FROM L; M DUAL;
  • 34. (ix) Perform a query using NVL. (General Functions) SELECT EMPNO, SAL, COMM, SAL + COMM, SAL + NVL(COMM, 0) FROM EMP_NM; EMPNO SAL COMM SAL+COMM SAL+NVL(COMM,0) 7369 800 800 7499 1600 300 1900 1900 7521 1250 500 1750 1750 7566 2975 2975 7654 1250 1400 2650 2650 7698 2850 2850 7782 2450 2450 7788 3000 3000 7839 5000 5000 7844 1500 0 1500 1500 7876 950 950 7902 3000 3000 12 rows selected. (x) Perform a query using DECODE. SELECT NAME, DECODE (NAME, 'Hammer', 'Mallet', 'Saw', 'Axe', 'Battery', 'Generator’, ’Unavailable') FROM ITEM_MASTER; NAME DECODE(NAME,'HAMMER','MALLET','SA Hammer Mallet Saw Axe Lawn Mover Unavailable Dish Washer Unavailable Baking Oven Unavailable Spark Plug Unavailable Alternator Unavailable Battery Generator Piston Unavailable 9 rows selected.