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

SQL Rev Class 12

The document contains a series of SQL-related questions and tasks, including identifying SQL functions, correcting SQL queries, predicting outputs of SQL commands, and writing SQL queries for various operations. It covers topics such as mathematical functions, string manipulation, and data types in SQL. Additionally, it includes practical exercises for applying SQL functions to real data scenarios.

Uploaded by

bentenkabaap
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

SQL Rev Class 12

The document contains a series of SQL-related questions and tasks, including identifying SQL functions, correcting SQL queries, predicting outputs of SQL commands, and writing SQL queries for various operations. It covers topics such as mathematical functions, string manipulation, and data types in SQL. Additionally, it includes practical exercises for applying SQL functions to real data scenarios.

Uploaded by

bentenkabaap
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

Which of the following SQL functions does not belong to the Math functions
category? (1)

i. POWER() ii. ROUND() iii. LENGTH() iv.


MOD()

2. 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? (1)

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;

3. Predict the output of the following query: (1)

SELECT LCASE (MONTHNAME ('2023-03-05'));

i. May

ii. March

iii. may

iv. march

4. With reference to SQL, identify the invalid data type. (1)

i. Date

ii. Integer
iii. Year

iv. Month

5.Write the output: (1)

(a) SELECT ROUND(99.867, 2);

(b) SELECT ROUND(63.97);

6. Predict the output of the following queries(2)

i. Select power(5,3); ii. Select mod(5,3);

7. Help Reshma in predicting the output of the following queries: (2)

i) select round(8.72,3); ii) select round(9.8);

8. Predict the output of the following queries(3)

i. select instr('[email protected]','.');

ii. select substr('[email protected]',7,4);

iii. select left('[email protected]',5);

9. Consider the given SQL string: (3)

“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.


10.
(3)

11.
(3)

12.
(8)
13. Write suitable SQL queries for the following: (5)

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’.

14. Reena is working with functions of MySQL. Explain her following(2)

i. What is the purpose of now () function?

ii. How many parameters does it accept?

15. Name the suitable MySQL function(s) to remove leading, trailing and both type
of space characters from a string.Also give MySQL queries to depict the same. (2)

16. Write SQL commands for the following (6)

a. command that will display the month from current time and date

b. To display the name of the day eg, Friday or Sunday from your date of birth,

dob.
c. To display the starting position of your first name(fname) from your whole

name (name).

d. To compute the remainder of division between two numbers, n1 and n27.

17. Considering the same string “Preoccupied” (2)

Write SQL commands to display

a. the position of the substring ‘cup’ in the string “Preoccupied”

b. the first 4 letters of the string

18. Consider a table SALESMAN with the following data: (5)

SNO SNAME SALARY BONUS DATE


OF JOIN

A01 Beena Mehta 30000 4525 9-10-


2019

A02 K. L. Sahay 50000 2534 13-03-


2018

B03 Nisha Thakkar 30000 3500


18-03-2017

B04 Leela Yadav 80000 NULL


31-12-2018

C05 Gautam Gola 20000 NULL


23-01-1989

Write SQL queries using SQL functions to perform the following operations:

a) Display salesman name and bonus after rounding off to zero decimal places.

b) Display the position of occurrence of the string “ta” in salesman names.

c) Display the four characters from salesman name starting from second

character.

d) Display the month name for the date of join of salesman

e) Display the name of the weekday for the date of join of salesman

19. Consider the decimal number x with value 8459.2654. (2)

Write commands in SQL


i) To round it off to a whole number.

ii) To round it to 2 places before the decimal.

10. Write the output of the following SQL queries: (2)

i) select power(instr('abcd412','1'),3);

ii) select length( substr(lower('abc 123'),1,3));

18.
(5)

You might also like