0% found this document useful (0 votes)
20 views6 pages

Database System

The document provides examples of SQL queries to retrieve data from database tables like EMP and DEPT. The queries demonstrate how to select, filter, calculate new columns, and format output. Column names, data types, structures are also shown using DESCRIBE.

Uploaded by

Abdulrab Chatha
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)
20 views6 pages

Database System

The document provides examples of SQL queries to retrieve data from database tables like EMP and DEPT. The queries demonstrate how to select, filter, calculate new columns, and format output. Column names, data types, structures are also shown using DESCRIBE.

Uploaded by

Abdulrab Chatha
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 SYSTEM

TASK 1:

Identify all possible errors in the statement


select ename as Name of employee,job,salary,sal x 12 as salary from emp
ANSWER:
select ename as "Name of employee", JOB, SAL, SAL * 12 AS SALARY FROM EMP

TASK 2:

Display the structure and data of employee table


ANSWER:
Describe emp;

TASK 3:

Select all the unique jobs from employee table. Name the column as Distinct jobs.
ANSWER:
select unique job as "Distinct jobs" from emp

TASK 4:

Display name, Salary and job of an employee in the following format with column
name as My job information.
ANSWER:
select ename ||' job is '|| job ||' and salary is '|| sal as "My Job Information" from emp;

TASK 5:

Display Name and annual salary of all the employees


ANSWER:
select ename as name, sal as salary, comm as comission, (sal*12+nvl(comm,0)) as "annual
salary" from emp;

TASK 6:

Display the employee name, salary, salary+commission as total salary, salary


increase by 25% and label this column new salary, bouns (new salary - salary).
ANSWER:
select ename as "employee name", sal as salary,comm as comission, (sal+nvl(comm,0)) as "total
salary", 0.25*sal+sal as "new salalry", (sal + sal*0.25) - sal as bonus from emp;

TASK 7:

Display record of all employees with dept no appearing as a first column.


ANSWER:
select deptno,empno,ename,job,mgr,hiredate,sal,comm from emp;
TASK 8:

Will this statement execute successfully?


SeLeCt eNaMe fRom EmP
ANSWER:
Yes, this execute correctly, no matter the characters are capital or small.

TASK 9:

Display grade and difference between high and low salary as Difference from
salgrade table.
ANSWER:
select grade,losal,hisal,hisal - losal as difference from salgrade;
TASK 10:

Write a query to display all the data from the Dept table. Separate each
column by a comma , Name the column The_Output as given in image below
ANSWER:
select deptno ||','|| dname ||','|| loc as "OUTPUT" from dept;

TASK 11:

Show the structure of department table.


ANSWER:
describe dept;

TASK 12:
Name the column headings as Emp#, Employee, Job, and Hire Date. respectively.
Rerun your query
ANSWER:
select empno as "Emp#",ename as "employee", job , hiredate as "hire date" from emp

TASK 13:

Display the name concatenated with the job. Separated by a comma and space,
and name the column Employee and Title.
ANSWER:
select ename ||', '|| job as "Employee and Title" from emp

You might also like