0% found this document useful (0 votes)
5 views

Database 7

Uploaded by

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

Database 7

Uploaded by

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

DATABASE PRACTICAL NO.

7 : Execute
SQL Queries using String , Arithmetic,
Date and Time, Aggregate Functions .

Practical related Questions:


1) Create table exp_7(emp_no number(2),emp_namevarchar(20),dept_no number (3),
dept_namevarchar(20),job_id number(4),salary number(7),hiredate date)

Table created.

a) select abs(-15) from dual;

ABS(-15)

15

1 rows returned in 0.00


CSV Export
seconds
b) selectexp(4) from dual;

EXP(4)

54.5981500331442390781102612028608784031

1 rows returned in 0.00 seconds CSV Export


c) select power(4,2) from dual;

POWER(4,2)

16

1 rows returned in 0.00 seconds CSV Export


d) select mod(10,3) from dual;

MOD(10,3)

1 rows returned in 0.00 seconds CSV Export


e) selectsqrt(16) from dual

SQRT(16)

1 rows returned in 0.00 seconds CSV Export


2) a) selectconcat('shreyas','NBA')from dual;

CONCAT('SHREYAS','NBA')

shreyasNBA

1 rows returned in 0.00 seconds


CSV Export

b) selectltrim('shreyass','s') from dual;

LTRIM('SHREYASS','S')

hreyass

1 rows returned in 0.00 seconds

c) selectrtrim('shreyass','s') from dual;

RTRIM('SHREYASS','S')

shreya

1 rows returned in 0.00 seconds CSV Export


d) select lower('SALES')from dual;

LOWER('SALES')

sales

1 rows returned in 0.00 seconds CSV Export


3) a) selectsysdate from dual;

SYSDATE

31-AUG-23

1 rows returned in 0.00 seconds CSV Export

b) selectnext_day(sysdate,'thur') from dual;

NEXT_DAY(SYSDATE,'THUR')

07-SEP-23

1 rows returned in 0.02 seconds CSV Export


c) selectadd_months(sysdate,2) from dual;

ADD_MONTHS(SYSDATE,2)

31-OCT-23

1 rows returned in 0.00 seconds CSV Export

d) selectlast_day(sysdate) from dual;

LAST_DAY(SYSDATE)

31-AUG-23

1 rows returned in 0.00 seconds CSV Export

e) selectmonths_between(sysdate,hiredate) from exp_7;

Exercise:
1) Create table exp_7(emp_no number(2),emp_namevarchar(20),dept_no number (3),
dept_namevarchar(20),job_id number(4),salary number(7),hiredate date)

Table created.
insert into exp_7 values(1,'saee',11,'cm',111,20000,'5-aug-2023')

1 row(s) inserted.
insert into exp_7 values(2,'deva',12,'cmm',112,30000,'6-aug-2023')

1 row(s) inserted.
insert into exp_7 values(3,'shreya',13,'cmmm',113,40000,'7-aug-2023')

1 row(s) inserted.
insert into exp_7 values(4,'samiksha',14,'cmmmm',114,50000,'8-aug-2023')

1 row(s) inserted.

insert into exp_7 values(5,'vaishnavi',15,'cmmmmm',115,60000,'9-aug-2023')

1 row(s) inserted.

a) selectsubstr('production sales',3,4) from dual;

SUBSTR('PRODUCTIONSALES',3,4)

oduc

1 rows returned in 0.00 seconds CSV Export

b) selectinstr('production','ro',3,2) from dual;

INSTR('PRODUCTION','RO',3,2)

1 rows returned in 0.00 seconds CSV Export

c) select greatest('10-jan-07','12-oct-07') from dual;

GREATEST('10-JAN-07','12-OCT-07')

12-oct-07

1 rows returned in 0.00 seconds CSV Export

d) selectdate_add('2014-01-01',interval 1 day) from dual;


e) select *from exp_7 where salary>(select avg(salary) from exp_7);

EMP_NO EMP_NAME DEPT_NO DEPT_NAME JOB_ID SALARY HIREDATE


4 samiksha 14 cmmmm 114 50000 08-AUG-23
5 vaishnavi 15 cmmmmm 115 60000 09-AUG-23

2 rowsin .03 CSV Export

f) select max(salary) from exp_7;

MAX(SALARY)

60000

1 rows returned in 0.00 seconds CSV Export

g) select min(salary) from exp_7;

MIN(SALARY)

20000

1 rows returned in 0.00 seconds CSV Export

h) select count(emp_name) from exp_7 where dept_name='cm';

COUNT(EMP_NAME)

1 rows returned in 0.05 seconds CSV Export

i) select sum(salary) from exp_7 where dept_name='cm';

SUM(SALARY)

20000
1 rows returned in 0.02 seconds CSV Export

You might also like