0% found this document useful (0 votes)
64 views

Revision SQL

The document provides examples of SQL commands with errors and asks the reader to identify the correct commands. It includes questions about finding the maximum salary by job, average salary by gender, youngest employee, lowest salary by city, and sum of salaries by city for employees hired after 2000. The last section provides a sample employee table and asks the reader to write SQL queries using functions. The document contains multiple sections with SQL queries to find aggregate values like maximum, minimum, average values grouped or filtered in various ways from sample employee tables. It tests the reader's knowledge of writing correct SQL commands with aggregation functions, grouping, filtering and uses sample data tables
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

Revision SQL

The document provides examples of SQL commands with errors and asks the reader to identify the correct commands. It includes questions about finding the maximum salary by job, average salary by gender, youngest employee, lowest salary by city, and sum of salaries by city for employees hired after 2000. The last section provides a sample employee table and asks the reader to write SQL queries using functions. The document contains multiple sections with SQL queries to find aggregate values like maximum, minimum, average values grouped or filtered in various ways from sample employee tables. It tests the reader's knowledge of writing correct SQL commands with aggregation functions, grouping, filtering and uses sample data tables
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

—----------------------------------------------------------------------------------------------------------------------------

Ravi has given the following command to obtain the Maximum salary
Select max(salary) from emp where group by job;
But he is not getting he desired result. Help him by writing the correct command.
a. Select max(salary) from emp where group by job;
b. Select Job, max(salary) from emp group by job;
c. Select job, max(salary) group by job from emp;
d. Select job, max(salary) from emp group by salary;

IV State the command to display average salary of each gender.


a. Select gender, avg(salary) from emp group by gender;
b. Select avg(salary) from emp group by gender;
c. Select gender, salary from emp group by gender;
d. Select gender, average(salary) from emp group by gender;
Choose the correct option
i) Only a
ii) Both a and d
iii) Only d
iv) None of these
V
Help Ritesh to write the command to display the name of the youngest employee?
a. select ename, min(DOJ) from student ;
b. select ename, max(DOJ) from student ;
c. select ename, min(DOJ) from student group by name ;
d. select ename, max(DOJ) from student group by job;

—----------------------------------------------------------------------------------------------------------
Manager of the company has given the following command to
obtain the lowest salary in different city. Select min(salary)
from Trainer where group by City; but he is not getting the
desired result. Help him by writing the correct command.

a. Select min(Salary) from Trainer where group by City


b. Select City, min(Salary) from Trainer group by Salary;
c Select City, min(Salary) from Trainer group by City;
d. Select City, min(Salary) group by class from Trainer
(iv) State the command to display the sum of salary obtained by

Trainers of each city who was hired after year 2000?

Select City, sum(Salary) from Trainer where


Hiredate"2000-12-31" group by City,
i.

Select City, sum(Salary) from Trainer group by City where


Hiredate>"2000-12-31"
Select City, sum(Salary) group by City from Trainer
having Hiredate>"2000-12-31"
—---------------------------------------------------------------------------------------

Consider a table Employee with the following data:


ENO ENAME SALARY BONUS DATE OF JOINING
E01 RamMehta 35000 NULL 02-11-2020
E02 ShyamSahay 55000 32.34 16-03-2008
E03 AlishaThakkar 32000 NULL 18-09-2020
E04 Neena Gupta 85000 28.54 31-11-1993
E05 GautamSingh 24000 NULL 30-09-2020
E06 Tez Singh 75000 22.47 25-07-1985
E07 ReemaSaxena55000 NULL 30-10-2020
Write SQL queries using SQL functions to perform the following operations: 5

a) Display employee name and bonus after rounding off to zero decimal
places.
b) Display the position of occurrence of the string “ee” in employee names.
c) Display the four characters from employee name starting from
second character.
d) Display the day name for the date of joining of employee
e) Display the name of the month from the date of joining of employee
—-----------------------------------------------------------------------------------------

Write the SQL functions which will perform the following operations:
i) To display the name of the day of the current date.
ii) To remove spaces from the beginning of a string, “ Python”.
iii) To display the name of the month eg, January or February from your date
of birth.
iv) To display the starting position of word “Information” from
“Information Technology”
v) To compute the power of two numbers a and b

You might also like