0% found this document useful (0 votes)
16 views5 pages

SQL-query Interview Question (1)

The document contains two main tables: EmployeeInfo and EmployeePosition, detailing employee data and their positions, along with several SQL query requirements for data retrieval and manipulation. Additionally, it includes Student, Program, and Scholarship tables, with various SQL queries to extract student information, GPA, and scholarship details. The queries cover a wide range of operations including filtering, aggregation, and string manipulation on the data.

Uploaded by

box690771
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views5 pages

SQL-query Interview Question (1)

The document contains two main tables: EmployeeInfo and EmployeePosition, detailing employee data and their positions, along with several SQL query requirements for data retrieval and manipulation. Additionally, it includes Student, Program, and Scholarship tables, with various SQL queries to extract student information, GPA, and scholarship details. The queries cover a wide range of operations including filtering, aggregation, and string manipulation on the data.

Uploaded by

box690771
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

EmployeeInfo Table:

EmpID EmpFname EmpLname Department Project Address DOB Gender


1 Sanjay Mehra HR P1 Hyderabad(HYD) 01/12/1976 M
2 Ananya Mishra Admin P2 Delhi(DEL) 02/05/1968 F
3 Rohan Diwan Account P3 Mumbai(BOM) 01/01/1980 M
4 Sonia Kulkarni HR P1 Hyderabad(HYD) 02/05/1992 F
5 Ankit Kapoor Admin P2 Delhi(DEL) 03/07/1994 M

EmployeePosition Table:

EmpID EmpPosition DateOfJoining Salary


1 Manager 01/05/2024 500000
2 Executive 02/05/2024 75000
3 Manager 01/05/2024 90000
2 Lead 02/05/2024 85000
1 Executive 01/05/2024 300000

•Write a query to fetch the EmpFname from the EmployeeInfo table in the upper
case and use the ALIAS name as EmpName.
•Write a query to fetch the number of employees working in the department ‘HR’.
•Write a query to get the current date.
•Write a query to retrieve the first four characters of EmpLname from the
EmployeeInfo table.
•Write a query to fetch only the place name(string before brackets) from the Address
column of EmployeeInfo table.
•Write a query to create a new table that consists of data and structure copied from
the other table.
•Write q query to find all the employees whose salary is between 50000 to 100000.
•Write a query to find the names of employees that begin with ‘S’
•Write a query to fetch top N records.
•Write a query to retrieve the EmpFname and EmpLname in a single column as
“FullName”. The first name and the last name must be separated with space.
Student Table

STUDENT_I FIRST_N LAST_N GP ENROLLMENT_D


MAJOR
D AME AME A ATE

8.7 Computer
Shivansh Mahajan 2021-09-01 09:30:00
201 9 Science

8.4
202 Umesh Sharma 2021-09-01 08:30:00 Mathematics
4

5.6
203 Rakesh Kumar 2021-09-01 10:00:00 Biology
0

9.2
204 Radha Sharma 2021-09-01 12:45:00 Chemistry
0

7.8
205 Kush Kumar 2021-09-01 08:30:00 Physics
5

9.5
206 Prem Chopra 2021-09-01 09:24:00 History
6

9.7
207 Pankaj Vats 2021-09-01 02:30:00 English
8

7.0
208 Navleen Kaur 2021-09-01 06:30:00 Mathematics
0

Program Table

STUDENT_REF_ID PROGRAM_NAME PROGRAM_START_DATE

201 Computer Science 2021-09-01 00:00:00

202 Mathematics 2021-09-01 00:00:00

208 Mathematics 2021-09-01 00:00:00


STUDENT_REF_ID PROGRAM_NAME PROGRAM_START_DATE

205 Physics 2021-09-01 00:00:00

204 Chemistry 2021-09-01 00:00:00

207 Psychology 2021-09-01 00:00:00

206 History 2021-09-01 00:00:00

203 Biology 2021-09-01 00:00:00

Scholarship Table

STUDENT_REF_ID SCHOLARSHIP_AMOUNT SCHOLARSHIP_DATE

201 5000 2021-10-15 00:00:00

202 4500 2022-08-18 00:00:00

203 3000 2022-01-25 00:00:00

201 4000 2021-10-15 00:00:00


1. Write a SQL query to fetch "FIRST_NAME" from the Student table in upper case and
use ALIAS name as STUDENT_NAME.
2. Write a SQL query to fetch unique values of MAJOR Subjects from Student table.
3. Write a SQL query to print the first 3 characters of FIRST_NAME from Student table.
4. Write a SQL query to find the position of alphabet ('a') int the first name column
'Shivansh' from Student table.
5. Write a SQL query that fetches the unique values of MAJOR Subjects from Student
table and print its length.
6. Write a SQL query to print FIRST_NAME from the Student table after replacing 'a' with
'A'.
7. Write a SQL query to print the FIRST_NAME and LAST_NAME from Student table into
single column COMPLETE_NAME.
8. Write a SQL query to print all Student details from Student table order by FIRST_NAME
Ascending and MAJOR Subject descending .
9. Write a SQL query to print details of the Students with the FIRST_NAME as 'Prem' and
'Shivansh' from Student table.
10. Write a SQL query to print details of the Students excluding FIRST_NAME as 'Prem'
and 'Shivansh' from Student table.
11. Write a SQL query to print details of the Students whose FIRST_NAME ends with 'a'.
12. Write an SQL query to print details of the Students whose FIRST_NAME ends with ‘a’
and contains six alphabets.
13. Write an SQL query to print details of the Students whose GPA lies between 9.00 and
9.99.
14. Write an SQL query to fetch the count of Students having Major Subject ‘Computer
Science’.
15. Write an SQL query to fetch Students full names with GPA >= 8.5 and <= 9.5.
16. Write an SQL query to fetch the no. of Students for each MAJOR subject in the
descending order.
17. Display the details of students who have received scholarships, including their names,
scholarship amounts, and scholarship dates.
18. Write an SQL query to show only odd rows from Student table.
19. Write an SQL query to show only even rows from Student table.
20. List all students and their scholarship amounts if they have received any. If a student
has not received a scholarship, display NULL for the scholarship details.
21. Write an SQL query to show the top n (say 5) records of Student table order by
descending GPA.
22. Write an SQL query to determine the nth (say n=5) highest GPA from a table.
23. Write an SQL query to determine the 5th highest GPA without using LIMIT keyword.
24. Write an SQL query to fetch the list of Students with the same GPA.
25. Write an SQL query to show the second highest GPA from a Student table using sub-
query.
26. Write an SQL query to show one row twice in results from a table.
27. Write an SQL query to list STUDENT_ID who does not get Scholarship.
28. Write an SQL query to fetch the first 50% records from a table.
29. Write an SQL query to fetch the MAJOR subject that have less than 4 people in it.
30. Write an SQL query to show all MAJOR subject along with the number of people in
there.
31. Write an SQL query to show the last record from a table.
32. Write an SQL query to fetch the first row of a table.
33. Write an SQL query to fetch the last five records from a table.
34. Write an SQL query to fetch three max GPA from a table using co-related subquery.
35. Write an SQL query to fetch three min GPA from a table using co-related subquery.
36. Write an SQL query to fetch nth max GPA from a table.
37. Write an SQL query to fetch MAJOR subjects along with the max GPA in each of these
MAJOR subjects.
38. Write an SQL query to fetch the names of Students who has highest GPA.
39. Write an SQL query to show the current date and time.
40. Write a query to create a new table which consists of data and structure copied from
the other table (say Student) or clone the table named Student.
41. Write an SQL query to update the GPA of all the students in 'Computer Science'
MAJOR subject to 7.5.
42. Write an SQL query to find the average GPA for each major.
43. Write an SQL query to show the top 3 students with the highest GPA.
44. Write an SQL query to find the number of students in each major who have a GPA
greater than 7.5.
45. Write an SQL query to find the students who have the same GPA as 'Shivansh
Mahajan'.

You might also like