SERVITE SCHOOL, CBSE
WORKSHEET (SQL)
CLASS : XII MARKS : 30
1. Predict the output of the following query:
SELECT MOD (9,0);
i. 0 ii. NULL iii. NaN iv. 9
2. Which of the following SQL functions does not belong to the Math functions
category?
i. POWER() ii. ROUND() iii. LENGTH() iv. MOD()
3. Raj, a Database Administrator, needs to display the average pay of workers from those
departments which have more than five employees. He is experiencing a problem while running the
following query:
SELECT DEPT, AVG(SAL) FROM EMP WHERE COUNT(*) > 5
GROUP BY DEPT;
Which of the following is a correct query to perform the given task?
i. SELECT DEPT, AVG(SAL) FROM EMP WHERE COUNT(*) > 5 GROUP BY DEPT;
ii. SELECT DEPT, AVG(SAL) FROM EMP HAVING COUNT(*) > 5
GROUP BY DEPT;
iii. SELECT DEPT, AVG(SAL) FROM EMP GROUP BY DEPT
WHERE COUNT(*) > 5;
iv. SELECT DEPT, AVG(SAL) FROM EMP GROUP BY DEPT
HAVING COUNT(*) > 5;
4. Predict the output of the following query:
SELECT LCASE (MONTHNAME ('2023-03-05'));
i. May ii. March iii. may iv. march
5. With reference to SQL, identify the invalid data type.
i. Date ii. Integer iii. Varchar iv. Month
6. In SQL, the equivalent of UCASE() is:
i. UPPERCASE () ii. CAPITALCASE() iii. UPPER() iv. TITLE ()
7. Consider the given SQL string:
“12#All the Best!”
Write suitable SQL queries for the following:
i. Returns the position of the first occurrence of the substring “the” in the given string.
ii. To extract last five characters from the string.
8. Write MySQL statements for the following:
i. To create a database named FOOD.
ii. To create a table named Nutrients based on the following specification:
9. Based on the SQL table CAR_SALES, write suitable queries for the following:
i. Display fuel wise average sales in the first quarter.
ii. Display segment wise highest sales in the second quarter.
iii. Display the records in the descending order of sales in the second quarter.
10. Predict the output of the following queries based on the table CAR_SALES
given above:
i. SELECT LEFT(SEGMENT,2) FROM CAR_SALES WHERE FUEL= "PETROL";
[Link] (QT2-QT1)/2 "AVG SALE" FROM CAR_SALES WHERE
SEGMENT= "SUV";
iii. SELECT SUM(QT1) "TOT SALE" FROM CAR_SALES WHERE
FUEL= "DIESEL";
11. Preeti manages database in a blockchain start-up. For business purposes, she created a table
named BLOCKCHAIN. Assist her by writing the following queries:
TABLE: BLOCKCHAIN
i. Write a query to display the year of oldest transaction.
ii. Write a query to display the month of most recent transaction.
iii. Write a query to display all the transactions done in the month of May.
iv. Write a query to count total number of transactions in the year 2022.
12. Write suitable SQL queries for the following:
i. To calculate the exponent for 3 raised to the power of 4.
ii. To display current date and time.
iii. To round off the value -34.4567 to 2 decimal place.
iv. To remove all the probable leading and trailing spaces from the column userid of the table named
user.
v. To display the length of the string ‘FIFA World Cup’.
13. Kabir has created following table named exam:
Help him in writing SQL queries to the perform the following task:
i. Insert a new record in the table having following values: [6,'Khushi','CS',85]
ii. To change the value “IP” to “Informatics Practices” in subject column.
iii. To remove the records of those students whose marks are less than 30 .
iv. To add a new column Grade of suitable datatype.
v. To display records of “Informatics Practices” subject.