Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

NAME: Deepak Maurya

CLASS: SE-IT ROLL NO.22

AIM: Population of the database by using inbuilt function in SQL.


Refer table EMP22

Q.1. Display all the details of the records whose employee name starts with A.

Ans:

Query:

select *

from EMP22

where Ename like'A%';

output:
NAME: Deepak Maurya
CLASS: SE-IT ROLL NO.22

Q.2. Display all the details of the records whose employee name does not starts with A.

Ans:

Query:

select *

from EMP22

where Ename not like'A%';

output:

Q.3. Display the rows whose salary ranges from 15,000 to 30,000.

Ans:

Query:

select *

from EMP22

where sal between 15000 and 30000;

output:
NAME: Deepak Maurya
CLASS: SE-IT ROLL NO.22

Q.4. Calculate the total and average salary amount of the employee table.

Ans:

Query:

select avg(sal)

from EMP22

output:

Query:

select sum(sal)

from EMP22

output:
NAME: Deepak Maurya
CLASS: SE-IT ROLL NO.22

Q.5. Count the total records in the employee table.

Ans:

Query:

select count(*)

from EMP22

output:

Q.6.Determine the max and min salary and rename the column as max_salary and min_salary.

Ans:

Query:

select max(sal)
NAME: Deepak Maurya
CLASS: SE-IT ROLL NO.22

from EMP22

output:

Query:

select min(sal)

from EMP22

output:

Query:
NAME: Deepak Maurya
CLASS: SE-IT ROLL NO.22

select max(sal) as max_sal,min(sal) as min_sal

from EMP22

Output:

Q.7. Display the month between 1-june-10 and 1-august-10 in full.

Ans:

Query:

select months_between

(to_date('08-02-2010','mm-dd-yyyy'),

to_date('06-02-2010','mm-dd-yyyy')) as months

from dual;

output:

Query:
NAME: Deepak Maurya
CLASS: SE-IT ROLL NO.22

select months_between('01-aug-2010','01-jun-2010')

from dual;

output:

Q.8. Display the last day of the month.

Ans:

Query:

select last_day('01-sep-2017')

from dual;

output:

Q.9. Find how many job titles are available in employee table with and without duplication.
NAME: Deepak Maurya
CLASS: SE-IT ROLL NO.22

Ans:

Query: with duplication

select count(job)

from EMP22

output:

Query: without duplication

select count(distinct job)

from EMP22

Output:
NAME: Deepak Maurya
CLASS: SE-IT ROLL NO.22

You might also like