Professional Documents
Culture Documents
My SQL Worksheet-12
(Aggregate Functions)
1. Consider the table TEACHER given below. Write commands in SQL for (1) and output for (2) to (5)
2. The ltem_No and Cost column of a table "ITEMS" are given below:
Based on this information, find the output of the following queries:
a) SELECT AVG(COST) FROM ITEMS;
b) SELECT COST +100 FROM ITEMS WHERE ITEM_NO > 103;
4. Consider the table Projects given below. Write commands in SOL fori) and output for i) to iii)
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 commands in SQL for (i) to (iv) and 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.
Ans
13. Consider the table FLIGHT given below. Write output.
14. What will be the output of the following queries on the basis of Employee table:
Ans.
20. Kunal has entered the following SQL command on Table ‘STUDENT’ that has TotalMarks as one of the columns.
SELECT COUNT (*) FROM STUDENT;
The output displayed is 20.
Then, Kunal enters the following command :
SELECT COUNT (*) FROM STUDENT WHERE TotalMarks <100;
The output displayed is 15.
Then, Kunal enters the following command :
SELECT COUNT (*) FROM STUDENT WHERE TotalMarks >= 100;
He predicts the output of the above query as 5. Do you agree with Kunal ? Give reason for your answer.
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;