Adbms 1.4
Adbms 1.4
EXPERIMENT
1.4
22MAM-2_B
Task to be
done:
EmployeeInfo
Table:
EmpID EmpFname EmpLname Department Project Address DOB Gender
1 Sanjay Mehra HR P1 Hyderabad(H 01/12/197 M
YD 6
)
2 Ananya Mishra Admin P2 Delhi(DEL) 02/05/196 F
8
3 Rohan Diwan Accoun P3 Mumbai(BOM) 01/01/198 M
t 0
4 Sonia Kulkar HR P1 Hyderabad(H 02/05/199 F
ni YD
) 2
5 Ankit Kapoo Admin P2 Delhi(DEL) 03/07/199 M
r
4
EmployeePosition Table:
EmpI EmpPositio DateOfJoinin Salary
D n g
1 Manager 01/05/2022 500000
2 Executive 02/05/2022 75000
3 Manager 01/05/2022 90000
2 Lead 02/05/2022 85000
1 Executive 01/05/2022 300000
Let us start by taking a look at some of the most frequently asked SQL Query
interview questions,
a) Write a query to fetch the EmpFname from the EmployeeInfo table in the upper
case and use the ALIAS name asEmpName.
b) Write a query to fetch the number of employees working in the department ‘HR’.
c) Write a query to get the cur ent date.
d) Write a query to retrieve the first four characters of EmpLname from the EmployeeInfo
table.
e) Write a query to fetch only the place name(string before brackets) from the Address
column of EmployeeInfo table.
f) Write a query to create a new table that consists of data and structure copied from the
other table.
g) Write q query to find all the employees whose salary is between 50000 to 100000.
h) Write a query to find the names of employees that begin with ‘S’
i) Write a query to fetch top N records.
j) Write a query to retrieve the EmpFname and EmpLname in a single column as
“FullName”. The first name and thelast name must be separated with space.
I’ve used online compiler of programiz.com for all question except for the part (c)
and (j) for these I've used XAMMP MYSQL as these two commands are showing the
error that sysdate() and concat() -> no such function exist.
Solution of part (a):
Query to fetch the date from system (by using XAMPP / MYSQL) -
select sysdate();
Output of the
query:
Solution of part (d):
of the query:
Query to fetch the data of employees whose names begins with ‘S’ -
Evaluation Grid: