Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

SQL Query Questions

AGGREGATE QUERIES

Employee table

ID Name Age Salary Company


1 Mark 25 10,000 Com-1
2 Nick 28 15,000 Com-2
3 Abel 23 7,000 Com-1
4 Justin 29 12,000 Com-3
5 Chris 31 14,000 Com-2

1) Write a SQL query to display the name as well as the length of the name from the above
table.
2) Write a SQL query to find the sum of all the salaries.
3) Write a SQL query to find the maximum salary.
4) Write a SQL query to find the average age of employees.
5) Write a SQL query to find the sum of salary where the employee’s age is greater than 25
according to the company.

Employee table

ID Name Age Salary Company


1 Mark 25 10,000 Com-1
2 Nick 28 15,000 Com-2
3 Abel 23 7,000 Com-1
4 Justin 29 12,000 Com-3
5 Chris 31 14,000 Com-2

1) Write a SQL query to display the total count where age is greater than 28.
2) Write a SQL query to find the distinct count of companies.
3) Write a SQL query to find the minimum age of the employee.
4) Write a SQL query to find the average salary of employees where age is greater than 25.
5) Write a SQL query to find the name and age where the employee’s salary is greater than
12,000 according to the company.
String Queries

Student

ID Fname Lname
1 Mark Ruffalo
2 Thomas Birdsey
3 Dominick Birdsey
4 Ruben Stone
5 Eddie Brock

1) Write a SQL query to convert Fname into uppercase.


2) Write a SQL query to convert Lname into lowecase.
3) Write a SQL query to reverse Fname.
4) Write a SQL query to concat Fname as uppercase and Lname as lowercase.
5) Write a SQL query to replace ‘k’ with ‘K’ from Mark.

Student

ID Fname Lname
1 Mark Ruffalo
2 Thomas Birdsey
3 Dominick Birdsey
4 Ruben Stone
5 Eddie Brock

1) Write a SQL query to convert Fname into lowercase.


2) Write a SQL query to display Lname as well as the length of Lname.
3) Write a SQL query to reverse Lname.
4) Write a SQL query to concat Fname and Lname and give the heading ‘Full Name’.
5) Write a SQL query to replace ‘ck’ with ‘CK’ from Brock.

You might also like