wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

SQL functions

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

The SQL statement to count distinct rows from a column is,

a)

select COUNT DISTINCT columnname AS total_rows from tablename;

b)

select (COUNT DISTINCT columnname) AS total_rows from tablename;

c)

select DISTINCT columnname AS total_rows from tablename;

d)

select COUNT (DISTINCT) AS total_rows from tablename;

2.

The COUNT() function also counts the NULL values.

a)

True

b)

False

3.

The SUM() function returns - - -

a)

some random values from the given column

b)

the total number of columns in the database

c)

the total number of tables in the given databases

d)

the total sum of a given numeric column

4.

In a column named "age", containing values 4, 5, 0, NULL, 6 the SQL statement "SELECT SUM(age) FROM students;" will return,

a)

3

b)

15

c)

0

d)

1

5.

The average value of the given numeric column is calculated by using - - - function.

a)

GETAVG()

b)

FINDAVG()

c)

AVG()

d)

AVGVALUE()

6.

Which one of the following is an Multiple row Functions?

a)

COUNT()

b)

LEN()

c)

AVERAGE()

d)

NOW()

7.

A table T_COUNT has 12 number values as 1, 2, 3, 32, 1, 1, null, 24, 12, null, 32, null. Predict the output of the below query.

SELECT COUNT (*) FROM t_count;
a)

12

b)

6

c)

9

d)

Throws exception because COUNT function doesn't works with NULL values

8.

A table stud has a column age with 7 records as 10, 12, 13, 32, null, 24, null. Predict the output of the below query.

SELECT COUNT (age) FROM stud;

a)

5

b)

6

c)

Error

d)

7

9.

A table Books has a column DateOfPurchase with 4 records as NULL, 22-1-2008, 18-3-2008, 24-1-2011. Predict the output of the below query.

SELECT MAX (dateofPurchase) FROM Books;

a)

24-1-2011

b)

22-1-2008

c)

NULL

d)

18-3-2008

10.

A table Books has a column DateOfPurchase with 4 records as NULL, 22-1-2008, 18-3-2008, 24-1-2011. Predict the output of the below query.

SELECT MIN (dateofPurchase) FROM Books;

a)

24-1-2011

b)

22-1-2008

c)

NULL

d)

18-3-2008