SQL 1
SQL 1
1. Consider the table TEACHER given below. Write commands in SQL for (1) and output for (2) to (5)
6. What is the purpose of ORDER BY clause in MySql ? How is it different from GROUP BY clause?
7. Consider the Table SHOPPE given below. Write command in MySql for (i) and output for (ii) to (iii).
8. Consider the table ‘PERSONS’ given below. write output for (i) to (iii).
9. There is a column HOBBY in a Table CONTACTS. The following two statements are giving different outputs. What
may be the possible reason ?
SELECT COUNT(*) FROM CONTACTS;
SELECT COUNT(HOBBY)FROM CONTACTS;
10. Consider the following table named "GYM" with details about fitness
items being sold in the store. Write output
11. Consider the following table named 'SBOP" with details of account
holders. Write output.
14. What will be the output of the following queries on the basis of Employee
table:
22. Observe the given table named “Loan” carefully and predict the output of the
following queries:
select count(file_no)-count(loan_amt) from loan;
Based on the given table give queries for the given questions.
Table name:Employee
i. Write a query to list the number of jobs available in the employees table.
ii. Write a query to get the maximum salary of an employee working as a Programmer.
iii. Write a query to get the average salary and number of employees working in the department 90.
iv. Write a query to get the number of employees with the same job.
v. Write a query to get the difference between the highest and lowest salaries.
vi. Write a query to find the manager ID and the salary of the lowest-paid manager.
vii. Write a query to get the department ID and the total salary payable in each department.
viii. Write a query to get the average salary for all departments employing more than 10 employees.
ix. Write a query to get the average salary for each job ID excluding programmer.