Dbms Questions 2
Dbms Questions 2
Table - I ( EMPLY )
Data for Client_Master
Empcode Empname Address Age Dept_Code
E101 Anjaly Anjaly Nivas, Thiruvalla 25 D301
E102 Bobby Alapuzha 28 D305
E103 Aravind Chennai 31 D305
E104 Lakshmi Mannar 55 D707
E105 Daisy Chaithram, Angamaly 35 D707
E106 Esha Mumbai 23 D707
E107 Georgy Pala 45 D909
E108 Prakash Vennikulam 36 D110
E109 Madhavan Mynakum, Kottayam 46 D202
E110 Anugraha Aparna, Angamaly 47 D301
E111 Deva Trichy 38 D301
E112 Saju Dhanya, Ernakulam 27 D202
E113 Priyesh Priya Nivas, Kottayam 26 D302
Table - II ( DEPT )
Data for Department
DEPTCODE DEPTNAME
D301 Sales
D302 Account
D707 Research
D909 Advertising
D202 Stock
D110 Computer
D305 Marketing
1. Display records from EMPY1 table for employees whose age is between 25 and 45.
2. Retrieve the Deptcode and total no of employees in each department.
3. Retrieve empcode, empname, address, deptcode for all employees in "account" and "stock"
departments.
IV. Consider the following relations that contains information about Trains:
Train (Train-id, T-name, from, to, distance, depart-time, arrival-time)
Driver (D-id, D-name, job, salary)
Swifts (D-id, Train-id)
iii . List the train ids of trains which contain ‘EXPRESS’ in the train name or is
swift by a driver whose name doesn’t end with ‘ank’.
Employee First- Last-name email Hire date Jod- salary Mang- Dept-
id name id id id
100 Steven king sking 1987-06- IT 5000 0 30
17
101 Neena Kochhar nkochhar 1987-06- IT 7000 100 40
18
102 Lex Dehann Ldehann 1987-06- CLE 3000 100 50
20 RK
103 Alexander Hunold Ahunold 1987-06- EEE 12000 101 40
21
104 Bruce Ernst Bernst 1987-06- CLE 3000 102 30
22 RK
105 David Austin Daustin 1987-06- EC 10000 101 50
23
106 Nancy Greenberg Ngreenber 1987-06- ME 13000 102 30
g 24
1. Write a query to find the name (first_name, last_name) of all employees who works
in the IT department
2. Write a query to find the name (first_name, last_name) and the salary of the
employees who have a higher salary than the employee whose last_name='Austin'
3. Write a query to find the name (first_name, last_name), and salary of the employees
whose salary is greater than the average salary.
VI.
Create a table employee and insert the following data:
1. Write a query to find the name (first_name, last_name) of the employees who are not
clerks
2. Write a query to find the name (first_name, last_name) and the salary of the
employees who have a higher salary than the employee whose last_name='Austin'.
3. Write a query to find the name (first_name, last_name) and hire date of the
employees who was hired after 'Alexander'.
VII.
Create a table employee and department and insert the following data:
1. Write a query to display the department ID and name and first name of clerk.
2. Write a query to display the job title and average salary of employees
3. Write a query to display department name, name (first_name, last_name), hire date,
salary of the manager for all managers whose experience is more than 15 years.
VIII.
Create a table employee and department and insert the following data:
1. Write a query to find the name (first_name, last_name), and salary of the employees
who earns more than the earning of Bruce.
2. Write a query to display the employee ID, first name, last name, and department
names of all employees.
3. Write a query to list the department ID and name of all the departments where no
employee is working.
IX.
Create a table employee and department and insert the following data:
1. Write a query to find the name (first_name, last_name) and hire date of the
employees who was hired after 'Neena'.
2. Write a query to find the name (first_name, last_name), and salary of the employees
who earns more than the average salary and works in any of the IT departments.
3. Write a query to display the department ID and name and first name of clerk.
X. Write a program to find the reverse of a number using the concept of stored procedure in
MySQL.
XI. Write a program to check whether a given number is Armstrong or not using the
concept of stored procedure in MySQL.
XII. Write a program to find the reverse of a number using the concept of Functions in
MySQL.
XIII. Write a program to check whether a given number is Armstrong or not using the concept
of functions in MySQL.