wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

SQL Functions Quiz

Total questions: 100

Worksheet time: 50mins

Name
Class
Date
1.

The avg() function in MySQL is an example of ______________.

a)

Math Function

b)

Text Function

c)

Date Function

d)

Aggregate Function

2.

The __________ Command can be used to make changes in the rows of a table in SQL.

a)

SELECT

b)

UPDATE

c)

DELETE

d)

INSERT

3.

The SQL Command that will display the current time and date is:

a)

Select now();

b)

Select date();

c)

Select time();

d)

Select sysdate();

4.

The mid() function in MySQL is an example of ______________.

a)

Math Function

b)

Text Function

c)

Date Function

d)

Aggregate Function

5.

The __________ function is used in SQL to find one string in another.

a)

Instr()

b)

Locate()

c)

Find()

d)

Search()

6.

MID() and SUBSTR() function in SQL serve the same purpose. (Yes/No)

a)

Yes

b)

No

7.

What is the output of the SQL command: Select round(15.193, -1)?

a)

10

b)

15.2

c)

15

d)

20

8.

Which SQL query will display the date after 10 days from the current date on your system?

a)

Select date_add(curdate(), interval 10 day);

b)

Select curdate()+10;

c)

Select sysdate()+10;

d)

Select adddate(curdate(), 10);

9.

What is the output of the SQL command: Select SUBSTR('ABCDEFG', -5, 3)?

a)

DEF

b)

CDE

c)

UBS

d)

EFG

10.

Which keyword is used to arrange the result of the ORDER BY clause in descending order?

a)

DSEC

b)

DES

c)

DESC

d)

ORDER_DESC

11.

The clause that is used to arrange the result of SQL command into groups

a)

Order by

b)

Group in

c)

Groups by

d)

Group by

12.

Find the Output of SQL command: select concat (concat ('Inform', 'atics'), 'Practices');

a)

Informatics Practices

b)

Informatic Practices

c)

Inform practices

d)

Inform atics practices

13.

Write the output of the following SQL command: select round (19.88,1);

a)

19.88

b)

19.8

c)

19.9

d)

20.0

14.

The now() function in MySQL is an example of:

a)

Math function

b)

Text function

c)

Date Function

d)

Aggregate Function

15.

The ............ command can be used to make changes in the structure of a table in SQL.

a)

ALTER

b)

UPDATE

c)

MODIFY

d)

CHANGE

e)

SELECT

16.

Write the SQL command that will display the time and date at which the command got executed.

a)

Select sysdate();

b)

Select now();

c)

Select current_date();

d)

Select current_time();

17.

Write the output of the following SQL command: select round(15.872,1);

a)

15.87

b)

15.9

c)

15.8

d)

16

18.

Manish wants to select all the records from a table named "Students" where the value of the column "FirstName" ends with an "a". Which of the following SQL statement will do this?

a)

SELECT * FROM Students WHERE FirstName = 'a';

b)

SELECT * FROM Students WHERE FirstName LIKE '%a';

c)

SELECT * FROM Students WHERE FirstName LIKE 'a%';

d)

SELECT * FROM Students WHERE FirstName LIKE '%a%';

19.

The command can be used to add a new column to the table.

a)

ALTER

b)

CREATE

c)

INSERT

d)

UPDATE

20.

Which SQL command is used to describe the structure of the table?

a)

DESC

b)

SELECT

c)

SHOW

d)

ALTER

21.

Foreign Key in a table is used to enforce:

a)

Data dependency

b)

Referential Integrity

c)

Views

d)

Index Locations

22.

A table ‘Student’ contains 5 rows and 4 columns initially. 2 more rows are added and 1 more column is added. What will be the degree and cardinality of the table student after adding these rows and columns?

a)

7, 5

b)

5, 7

c)

5, 5

d)

None of the above

23.

Insert into student values(1,’ABC’,’10 Hari Nagar’) is a type of which command:

a)

DML

b)

DDL

c)

TCL

d)

DCL

24.

What will be the output of - select mid(‘Python Programming’,3,9);

a)

ton Progr

b)

ton Progr

c)

hton Prog

d)

htonProg

25.

Write the output of the following SQL statement: SELECT TRUNCATE(15.79,-1), TRUNCATE(15.79,0), TRUNCATE(15.79,1);

a)

15 15 15.7

b)

10 15.7 15.9

c)

10 15 15.7

d)

10 10 15.9

26.

The COUNT() in MySQL is an example of:

a)

Math function

b)

Text function

c)

Date Function

d)

Aggregate Function

27.

....... which of the following sublanguages of SQL is used to query?

a)

DDL

b)

DML

c)

TCL

d)

DCL

28.

Which command is used to retrieve information from the database and to insert tuples into, delete tuples from, and modify tuples in the database?

a)

DML

b)

DDL

c)

Query

d)

Relational Schema

29.

The ______ clause of SELECT query allows us to select only those rows in the result that satisfied a specified condition.

a)

WHERE

b)

FROM

c)

HAVING

d)

LIKE

30.

What will be the output of the following SQL command: `select substr("COMPUTER",3,4);`

a)

MPUT

b)

PUTE

c)

PU

d)

MP

31.

The now() function in MySQL is an example of ______.

a)

Math function

b)

Text function

c)

Date Function

d)

Aggregate Function

32.

Which command is used to make the changes in a table permanent?

a)

ROLLBACK

b)

COMMIT

c)

SAVEPOINT

d)

DELETE

33.

Which SQL command will display the current month from the date and time?

a)

MONTH()

b)

CURRENT_DATE()

c)

NOW()

d)

DATE()

34.

Which of the following keywords will you use in the following query to display all the records of students whose name starts with S? `SELECT * from student where name__"S%"`

a)

LIKE

b)

IN

c)

BETWEEN

d)

DISTINCT

35.

Which of the following is an aggregate function?

a)

Upper()

b)

Trim()

c)

Date()

d)

Sum()

36.

Write the output of the following SQL command: SELECT left("Jammu Region", 5);

a)

Region

b)

Jammu

c)

Jammu Region

d)

None of the above.

37.

What will be the output of the following code? SELECT MOD(14,3);

a)

1

b)

2

c)

3

d)

0

38.

What will be the result of the following query based on the table given here? SELECT COUNT(Salary) FROM Instructor;

a)

4

b)

5

c)

6

d)

7

39.

Write the command to delete all the data of the table 'activity' retaining only structure.

a)

DELETE FROM activity;

b)

DROP TABLE activity;

c)

TRUNCATE TABLE activity;

d)

DELETE * FROM activity;

40.

Write the output for the following SQL command: SELECT round(15.193, -1);

a)

15

b)

10

c)

20

d)

0

41.

Write a SQL query to display date after 20 days of current date on your system.

a)

SELECT CURDATE() + 20;

b)

SELECT DATE_ADD(CURDATE(), INTERVAL 20 DAY);

c)

SELECT CURDATE() + INTERVAL 20 DAY;

d)

SELECT ADDDATE(CURDATE(), 20);

42.

Write the output for the following SQL command: SELECT SUBSTR('ABCDEFG', -5, 3);

a)

CDE

b)

DEF

c)

ABC

d)

GFE

43.

Which keyword is used to arrange the result of order by clause in descending order?

a)

DSEC

b)

DESC

c)

ORDER_DESC

d)

REVERSE

44.

Write the output of the following SQL command: `Select round(14.872,1)`

a)

14.87

b)

14.9

c)

14.8

d)

15

45.

The ________ command can be used to change the size of a column in a table.

a)

UPDATE

b)

ALTER

c)

MODIFY

d)

DELETE

46.

The ________ command can be used to make changes in the rows of a table in SQL.

a)

INSERT

b)

ALTER

c)

UPDATE

d)

DELETE

47.

Write the output of the following SQL command: `select round(49.88);`

a)

49.88

b)

49.8

c)

49.0

d)

50

48.

Write the output of the following SQL command: `select round(19.88,1);`

a)

19.88

b)

19.8

c)

19.9

d)

20.0

49.

Select count(*) from Employee; The above query will not consider the following:

a)

Numeric value

b)

Text value

c)

Null value

d)

Date value

50.

Which of the following is/are not correct aggregate functions in SQL?

a)

AVG()

b)

COUNT()

c)

TOTAL()

d)

MAX()

51.

The ________ command can be used to make changes in the definition of a table in SQL.

a)

UPDATE

b)

ALTER

c)

MODIFY

d)

DELETE

52.

Write the SQL clause used to sort the records of a table.

a)

GROUP BY

b)

ORDER BY

c)

SORT BY

d)

FILTER BY

53.

Write the output of the following SQL command: `select round(15.857,-1);`

a)

15.8

b)

15.9

c)

15.0

d)

20

54.

The now() function in MySQL is an example of _____________.

a)

Math function

b)

Text function

c)

Date Function

d)

Aggregate Function

55.

The command that can be used to make changes in the structure of a table in SQL is _____________.

a)

ALTER

b)

UPDATE

c)

MODIFY

d)

CHANGE

56.

Which SQL command will display the time and date at which the command got executed?

a)

SELECT TIME();

b)

SELECT DATE();

c)

SELECT NOW();

d)

SELECT CURRENT();

57.

In SQL, NULL value means:

a)

0 value

b)

1 value

c)

None value

d)

None of the above

58.

Find the output of the SQL query: SELECT MOD(11, 3);

a)

1

b)

2

c)

3

d)

0

59.

The MAX() function in MySQL is an example of _____________.

a)

Math function

b)

Text function

c)

Date Function

d)

Aggregate Function

60.

Write the output of the following SQL command: select round(314.82,-1);

a)

314.0

b)

310.0

c)

314.8

d)

300.0

61.

What will be the output of the following SQL command: SELECT LTRIM(" RAJKUMAR ");

a)

"RAJKUMAR"

b)

" RAJKUMAR"

c)

"RAJKUMAR "

d)

"RAJKUMAR " (with spaces removed from right side)

62.

Write the output of the following SQL command: select pow(2.37,3.45);

a)

17.62

b)

19.62

c)

18.35

d)

15.82

63.

Having clause is used with _____________ function.

a)

Math function

b)

Text function

c)

Aggregate function

d)

Date function

64.

What is the output of the query: `select instr('Toolbarbar','bar');`?

a)

3

b)

5

c)

7

d)

9

65.

The `alter()` function in MySQL is part of which command?

a)

DDL command

b)

DML command

c)

TCL command

d)

DCL command

66.

Which command can be used to arrange data in some order in a table in SQL?

a)

GROUP BY

b)

ORDER BY

c)

SELECT

d)

WHERE

67.

Which clause is used with the SELECT command to search for a specific pattern in strings?

a)

WHERE

b)

LIKE

c)

GROUP BY

d)

HAVING

68.

What is the difference between single row functions and multiple row functions?

a)

Single row functions work on multiple rows, while multiple row functions work on one row.

b)

Single row functions return one output per row, while multiple row functions return one output for a group of rows.

c)

Single row functions are used for sorting, while multiple row functions are used for filtering.

d)

Single row functions are used for grouping, while multiple row functions are used for ordering.

69.

What is the difference between the ORDER BY and GROUP BY clause when used along with the SELECT statement?

a)

ORDER BY is used for grouping rows, while GROUP BY is used for sorting rows.

b)

ORDER BY is used to sort rows, while GROUP BY is used to group rows based on column values.

c)

ORDER BY is used for filtering rows, while GROUP BY is used for aggregating rows.

d)

ORDER BY is used for pattern matching, while GROUP BY is used for searching.

70.

Consider the decimal number X with value 8459.2654. Write the SQL command to round it off to a whole number.

a)

`select round(8459.2654, 0);`

b)

`select round(8459.2654, 1);`

c)

`select round(8459.2654, -1);`

d)

`select round(8459.2654, 2);`

71.

Consider the decimal number X with value 8459.2654. Write the SQL command to round it off to 2 places before the decimal.

a)

`select round(8459.2654, 0);`

b)

`select round(8459.2654, 1);`

c)

`select round(8459.2654, -2);`

d)

`select round(8459.2654, 2);`

72.

Anjali writes the following commands with respect to a table `employee` having fields: `empno`, `name`, `department`, and `commission`: - Command1: `Select count(*) from employee;` - Command2: `Select count(commission) from employee;` She gets the output as 4 for the first command but gets an output of 3 for the second command. Why is there a difference in the outputs?

a)

Command1 counts all rows in the table, including NULL values, while Command2 only counts non-NULL values in the `commission` column.

b)

Command1 counts only non-NULL values in the table, while Command2 counts all rows in the `commission` column.

c)

Both commands count all rows in the table, but Command2 excludes duplicate values.

d)

Command1 and Command2 both count only non-NULL values in the table.

73.

Consider the SQL string: "Preoccupied". Write the SQL command to display the substring "cup".

a)

select substr("Preoccupied", 4);

b)

select substr("Preoccupied", 6, 3);

c)

select substr("Preoccupied", 1, 3);

d)

select substr("Preoccupied", 8, 3);

74.

Consider the SQL string: "Preoccupied". Write the SQL command to display the first 4 letters of the string.

a)

select left("Preoccupied", 4);

b)

select substr("Preoccupied", 1, 4);

c)

select right("Preoccupied", 4);

d)

select mid("Preoccupied", 4);

75.

What is the difference between the `WHERE` and `HAVING` clauses when used along with the `SELECT` statement?

a)

`WHERE` is used to filter rows before grouping, while `HAVING` is used to filter groups after grouping.

b)

`WHERE` is used to filter groups, while `HAVING` is used to filter rows.

c)

Both `WHERE` and `HAVING` are used to filter rows, but `HAVING` supports aggregate functions.

d)

`WHERE` is used to filter rows, while `HAVING` is used to filter rows without aggregate functions.

76.

What is the difference between the `UPDATE` and `ALTER` commands in SQL?

a)

`UPDATE` is used to modify the structure of a table, while `ALTER` is used to modify data in a table.

b)

`UPDATE` is used to modify data in a table, while `ALTER` is used to modify the structure of a table.

c)

Both `UPDATE` and `ALTER` are used to modify data in a table.

d)

`UPDATE` is used to delete data, while `ALTER` is used to add new rows.

77.

What is the output of the query `SELECT SUBSTR('Aakila', -3);`?

a)

'Aak'

b)

'ila'

c)

'kil'

d)

'Aakila'

78.

What is the output of the query `SELECT LEFT('Toolbar', 4);`?

a)

'Tool'

b)

'Toolb'

c)

'Toolbar'

d)

'bar'

79.

Why does the query `SELECT count(*) FROM FLIGHT;` return 5, while `SELECT count(DESTINATION) FROM FLIGHT;` returns 3?

a)

The column DESTINATION contains NULL values, and aggregate functions like COUNT ignore NULL values.

b)

The column DESTINATION contains duplicate values, and COUNT ignores duplicates.

c)

The column DESTINATION is empty, so COUNT returns 0.

d)

The column DESTINATION contains only numeric values, and COUNT ignores non-numeric values.

80.

What is the output of the query `SELECT MOD(11,4) "Modulus", POWER(3,2) "Raised";`?

a)

Modulus: 2, Raised: 6

b)

Modulus: 3, Raised: 9

c)

Modulus: 1, Raised: 6

d)

Modulus: 3, Raised: 6

81.

What is the output of the query `SELECT LENGTH('CORONA COVID-19');`?

a)

15

b)

14

c)

16

d)

13

82.

What is the output of the query `SELECT LCASE('COMputer Science');`?

a)

'COMputer Science'

b)

'computer science'

c)

'COMPUTER SCIENCE'

d)

'Computer Science'

83.

What SQL command would you use to round the number 7459.3654 to a whole number?

a)

select round(7459.3654, 0)

b)

select round(7459.3654, -1)

c)

select round(7459.3654, 1)

d)

select round(7459.3654, 2)

84.

What SQL command would you use to round the number 7459.3654 to two places before the decimal?

a)

select round(7459.3654, 2)

b)

select round(7459.3654, -2)

c)

select round(7459.3654, 0)

d)

select round(7459.3654, -1)

85.

Why does the SQL command `SELECT COUNT(COMMISSION) FROM EMPLOYEE` return a lower count compared to `SELECT COUNT(*) FROM EMPLOYEE`?

a)

Because the column commission contains NULL values, which are excluded in aggregate functions.

b)

Because the column commission contains duplicate values.

c)

Because the column commission contains only numeric values.

d)

Because the column commission contains empty strings.

86.

Which SQL command can be used to extract the substring "MOT" from the string "SELFMOTIVATION" starting at position 5?

a)

select substr("SELFMOTIVATION", 5, 3)

b)

select substr("SELFMOTIVATION", 5, 5)

c)

select substr("SELFMOTIVATION", 3, 5)

d)

select substr("SELFMOTIVATION", 5, 2)

87.

Which SQL command can be used to find the position of the substring "MOTIV" in the string "SELFMOTIVATION"?

a)

select instr("SELFMOTIVATION", "MOTIV")

b)

select substr("SELFMOTIVATION", "MOTIV")

c)

select position("SELFMOTIVATION", "MOTIV")

d)

select locate("SELFMOTIVATION", "MOTIV")

88.

What is the main objective of datatypes in SQL?

a)

To identify the type of data and its associated functions.

b)

To store only numeric data in a table.

c)

To perform mathematical operations on data.

d)

To create relationships between tables.

89.

Which SQL command would you use to round the decimal number 278.6975 to give an output of 279?

a)

select round(278.6975, 0)

b)

select round(278.6975, -1)

c)

select round(278.6975, 1)

d)

select round(278.6975, 2)

90.

Which SQL command would you use to round the decimal number 278.6975 to give an output of 280?

a)

select round(278.6975, -1)

b)

select round(278.6975, 0)

c)

select round(278.6975, 1)

d)

select round(278.6975, 2)

91.

Consider a table "Employee" with fields - empno, name, department, salary. Manvendra has entered the following SQL command: `SELECT * FROM Employee where Salary = NULL;` But the query is not executing successfully. What do you suggest to him in order to execute this query correctly?

a)

Use `SELECT * FROM Employee where Salary IS NULL;`

b)

Use `SELECT * FROM Employee where Salary = 0;`

c)

Use `SELECT * FROM Employee where Salary != NULL;`

d)

Use `SELECT * FROM Employee where Salary IS NOT NULL;`

92.

Write a SQL query to display the details of those employees whose Salary column has some values.

a)

SELECT * FROM Employee where Salary IS NOT NULL;

b)

SELECT * FROM Employee where Salary = NULL;

c)

SELECT * FROM Employee where Salary > 0;

d)

SELECT * FROM Employee where Salary IS NULL;

93.

Consider the following SQL string: "Master Planner". Write SQL commands to display the position of the substring 'Plan' in the string "Master Planner".

a)

SELECT instr("Master Planner", "Plan");

b)

SELECT substr("Master Planner", 1, 6);

c)

SELECT right("Master Planner", 4);

d)

SELECT instr("Master Planner", "Master");

94.

What are multiple row functions?

a)

Functions that operate on multiple rows and return a single result.

b)

Functions that operate on a single row and return multiple results.

c)

Functions that operate on multiple rows and return multiple results.

d)

Functions that operate on a single row and return a single result.

95.

Consider the decimal number N with value 87654.9876. Write commands in SQL to round it off to a whole number.

a)

SELECT round(87654.9876, 0);

b)

SELECT round(87654.9876, -1);

c)

SELECT round(87654.9876, 1);

d)

SELECT round(87654.9876, 2);

96.

State two differences between single row functions and multiple row functions.

a)

Single row functions operate on each row individually, while multiple row functions operate on a group of rows.

b)

Single row functions return multiple results, while multiple row functions return a single result.

c)

Single row functions are used for aggregation, while multiple row functions are used for formatting.

d)

Single row functions operate on a group of rows, while multiple row functions operate on each row individually.

97.

What is the difference between single row functions and multiple row functions in SQL?

a)

Single row functions return one output per group, whereas multiple row functions return one output per row.

b)

Single row functions return one output per row, whereas multiple row functions return one output per group.

c)

Single row functions and multiple row functions both return one output per row.

d)

Single row functions and multiple row functions both return one output per group.

98.

What is the purpose of the "order by" clause in SQL?

a)

To group rows in a column and apply aggregate functions.

b)

To sort the contents of a table in ascending or descending order based on a specified column.

c)

To filter rows based on a condition.

d)

To join two tables based on a common column.

99.

What is the output of the following SQL query: `Select round(123.93);`?

a)

123

b)

124

c)

123.9

d)

123.93

100.

What is the correct SQL command to extract the substring "Helps" from the string "Mental Toughness Helps You Succeed"?

a)

`Select mid("Mental Toughness Helps You Succeed", 8, 9);`

b)

`Select mid("Mental Toughness Helps You Succeed", 8, 5);`

c)

`Select left("Mental Toughness Helps You Succeed", 6);`

d)

`Select right("Mental Toughness Helps You Succeed", 7);`