I have started posting a series of sqlserver queries that are asked
in interviews. This can be a great start of practising the queries.
I will provide the answers at the end of each part.
Happy Job Hunt!!
ALL THE BEST!!
1.
Write a query to display
the employee id, employee name along with their manager name based on the below
tables.
Employee
Emp ID
|
Name
|
1
|
X
|
2
|
Y
|
3
|
Z
|
Manager
Emp ID
|
Mgr ID
|
1
|
3
|
2
|
3
|
3
|
2.
I have Member and Employee
tables.
Member Table Employee Table
o
Member ID Employee ID
o
First Name Member ID
o
Last Name EmployeeManagerMemberID
(2a) Get Employee Name and Manager name?
(2b) Get the name of the employee who doesn’t have manager?
3.
I have Employee and Department
table. The
Employee table contains columns like empid, deptid,
salary.
Department table contains columns like deptid,
deptName.
3(a) Write a query to get count of employee for each
department.
The output should contain two columns (DeptName, count of employees).
3(b) Write a query to get the list of department which are having employee more
than 10?
3(c) Write a query to get the list of employees who
are there in the multiple
departments?
4.
I have 3 tables Student,
Subject and Student Subject tables. The structure of the tables are as follows
Student Table :
stud_ID, stud_name,stud_address
Subject Table :
sub_ID, sub_name
StudentSubject Table : stud_ID, sub_ID
4(a) Display student name, student
address and subject name for a provided student ID?
4(b) Display the entire student
names who are not studying the provided
subject name?
5.
I have a
table With Column A having 6 rows 1, 2, 3,4,5,6 respectively. Write a query to
get the sum of value pair equal to a given number. Eg: If the given number is 5
then it should display rows like 1,4 & 2,3 etc.
ReplyDeleteGreat beat ! I would like to apprentice at the same time as you amend your website, how could i subscribe for a blog site? The account aided me a appropriate deal. I have been a little bit familiar of this your broadcast offered vivid transparent idea www.gmail.com login