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

SQL Questions

The document outlines a series of SQL tasks including creating an 'Employee' database and two tables: 'Emp_details' and 'Dept'. It provides specific queries for inserting records, modifying table structures, updating data, and retrieving various statistics about employees and departments. Additionally, it includes commands for calculating averages, counts, and displaying records based on certain criteria.

Uploaded by

rahulbqmba12
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

SQL Questions

The document outlines a series of SQL tasks including creating an 'Employee' database and two tables: 'Emp_details' and 'Dept'. It provides specific queries for inserting records, modifying table structures, updating data, and retrieving various statistics about employees and departments. Additionally, it includes commands for calculating averages, counts, and displaying records based on certain criteria.

Uploaded by

rahulbqmba12
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

SQL Questions

1. Write queries to create an “Employee” Database and “Emp_details” table with the
following fields:
Emp_id | Name | Address | Age | DOB | Mobile
Create another table “Dept” with the following structure:
Empid | Dept_name | Salary | Dept_id

Query to create database

Query to create Emp_details

Query to create Dept table


2. Write queries to insert 10 records into both the tables.

(insert data into emp_details)


(insert into dept table)
3. Implement the following SQL commands on ‘Emp_details’ and ‘Dept’ tables and show the
output:

A. Add new attribute “Gender” to the Emp_details table.

B. Add primary key constraint on the column “Emp_id”.


C. UPDATE the age to 27 for the Employee named “Neha” in “Emp_details” table.

D. Display the details of all the employees in decreasing order of their age from table
“emp_details”.

E. Delete the records of those employees whose age is more than 60 from the table
“emp_details”.
F. Display the department name and count of employees in each department from the table
“Dept”.
G. Write SQL query to display the average salary of Employees.

H. Display the name and age of those employees whose age is more than 25 and surname is
“Kumar” from the table “emp_details”.

I. Calculate and show the average salary of departments -Finance and HR. from the table
“Dept”.
J. Write SQL query to display the total number of male Employees in the table.

K. Display the unique departments from the table “Dept”.

L. Display the Name, Address and salaries of the employees who are staying in ‘Vaishali’.
M. Display the employee id, name and salary of all the employees whose department id is
either ‘D2’ or ‘D3’.

N. Display the maximum salary in each department.


O. Display all the records of table “Emp_Details” in decreasing order of age.

P. Display the Cartesian product of the tables ‘Emp_Details and Dept’.


Q. Increment the salary of all employees by 1000 in the table “Dept”.
R. Display emp_id, employee name and department name of all employees whose age is more
than 20.

S. Display the average salary of each department.

You might also like