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

DB02

The document describes creating EMP and DEPT tables in a database and provides 10 SQL queries: 1) Display employee names and joining dates 2) Display employees earning over Rs. 5,000 labeled "Employee" 3) Display employee names and numbers alphabetically by name

Uploaded by

Rahul Kansal
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
130 views

DB02

The document describes creating EMP and DEPT tables in a database and provides 10 SQL queries: 1) Display employee names and joining dates 2) Display employees earning over Rs. 5,000 labeled "Employee" 3) Display employee names and numbers alphabetically by name

Uploaded by

Rahul Kansal
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment-1

creation of emp table:

create table emp(emp_no number(2) primary key, emp_name varchar(25),


designation char(4), joining_data date, salary number(7,2), dept_no number(2));

creation of dept table:

create table dept(dept_no number(2) primary key, dept_name varchar(25), budget


number(15,2), manager varchar(25));

Write SQL queries for the following :

1. Display each employee’s name and date of joining.


Ans: select emp_name, joining_date from emp;

2. Display employees earning more than Rs.5,000. Label the column name
“Employee”.
Ans: select emp_name as "Employee" from emp where salary>5000;

3. Display all employee names and employee numbers in the alphabetical


order of names.
Ans: select emp_no, emp_name from emp ordered by emp_name;

4. Display all employee names containing the letter “S”.


Ans: select emp_name from emp where emp_name like 's%';

5. Display the employees hired in 1981.


Ans: select emp_name from emp where to_char(joining_date,’ yyyy’)=1981;
6. Display the minimum and maximum salary.
Ans: select max(salary), min(salary) from emp;

7. Display the list of employees along with their department name and its
manager.
Ans: select emp.emp_name, dept.dept_name, dept.manager from emp inner join
dept on emp.dept_no=dept.dept_no;

8. Display the number of different employees listed for each department.


Ans: select count(emp.emp_name ) from emp,dept where
emp.dept_no=dept.dept_no group by emp.dept_no;

9. Delete the records of all the employees hired in 1981 from EMP table.
Ans: delect from emp where to_char(joining_date, ‘yyyy’)=1981;

10. Update the salary of all the employees to Rs. 10,000.


Ans: update emp set salary=10000;

You might also like